server

package
v0.0.0-...-5b08584 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package server manages the wiki server

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}

ErrNotFound is a standard error for not found.

View Source
var Mayors = []*Mayor{
	{TermStart: 1819, TermEnd: 1833, Name: "Georg Jakob Heinrich Mack"},
	{TermStart: 1833, TermEnd: 1859, Name: "Gottfried Völter"},
	{TermStart: 1859, TermEnd: 1866, Name: "Friedrich Winter"},
	{TermStart: 1866, TermEnd: 1867, Name: "Friedrich Wehrle"},
	{TermStart: 1867, TermEnd: 1877, Name: "Carl Greiner"},
	{TermStart: 1877, TermEnd: 1877, Name: "Carl Bunz, Executor"},
	{TermStart: 1877, TermEnd: 1878, Name: "Louis Junginger"},
	{TermStart: 1878, TermEnd: 1902, Name: "Christian Friedrich Schlagentweith"},
	{TermStart: 1902, TermEnd: 1903, Name: "Wilhelm Lösch"},
	{TermStart: 1903, TermEnd: 1935, Name: "Eugen Jaekle"},
	{TermStart: 1935, TermEnd: 1935, Name: "Gustav Müller"},
	{TermStart: 1935, TermEnd: 1945, Name: "Rudolf Meier"},
	{TermStart: 1945, TermEnd: 1945, Name: "Paul Schwaderer"},
	{TermStart: 1945, TermEnd: 1946, Name: "Werner Plappert"},
	{TermStart: 1946, TermEnd: 1948, Name: "Werner Kliefoth"},
	{TermStart: 1948, TermEnd: 1956, Name: "Karl Rau"},
	{TermStart: 1956, TermEnd: 1957, Name: "Ernst Langensee, Executor"},
	{TermStart: 1957, TermEnd: 1969, Name: "Elmar Doch"},
	{TermStart: 1969, TermEnd: 1993, Name: "Martin Hornung"},
	{TermStart: 1993, TermEnd: 2000, Name: "Helmut Himmelsbach"},
	{TermStart: 2000, Name: "Bernhard Ilg", Current: true},
}

Mayors is a list of formated mayors and their years in office

Functions

func MayorCtx

func MayorCtx(next http.Handler) http.Handler

MayorCtx is custom middleware to load a Mayor object, from the url

Types

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse renderer type for handling all sorts of errors.

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

Render formats the custom error object with a http status code

type Mayor

type Mayor struct {
	TermStart int    `json:"termStart"`
	TermEnd   int    `json:"termEnd"`
	Name      string `json:"name"`
	Current   bool   `json:"current"`
}

Mayor is the formated structure of a mayor

type Server

type Server struct {
	Router *chi.Mux
}

Server is a struct that contains, all the required pieces to effectively run the main server and handles all the routing to handle different routes.

func (*Server) Initialize

func (s *Server) Initialize()

Initialize prepares a server along with all middleware.

func (*Server) Run

func (s *Server) Run(addr string)

Run starts the API server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL