Documentation ¶
Overview ¶
Package webapps handles the creation of routes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle func(http.ResponseWriter, *http.Request, httprouter.Params) error
Handle responds to an HTTP request.
type Middleware ¶
Middleware envelops Handle to intercept HTTP requests and modify responses.
type WebApp ¶
type WebApp struct { // OnError is called after a Handle returned an error. OnError func(writer http.ResponseWriter, request *http.Request, params httprouter.Params, err error) // OnPanic is called after a Handle panicked. OnPanic func(writer http.ResponseWriter, request *http.Request, params httprouter.Params, recoveryInfo interface{}) // Router is the underlying router. Router *httprouter.Router // contains filtered or unexported fields }
WebApp represents a web application or web site. Router gives access to the underlying router and its settings. OnError and OnPanic can be overwritten by custom functions to handle errors and panics.
func New ¶
New returns a new WebApp. OnError and OnPanic are initalized with a default function for handling errors and panics, and can be overwritten by a custom function.
func (*WebApp) Middleware ¶
func (w *WebApp) Middleware(middleware Middleware)
Middleware adds a function that is executed before any Handle is executed. Middlewares added after calling Route are ignored.
func (*WebApp) StartWithTLS ¶
StartWithTLS starts the HTTP server with TLS (Transport Layer Security).