Documentation ¶
Overview ¶
Package middleware provides middleware components for the HTTP listener. This includes functions to handle logging HTTP requests, CORS access control, and OPTIONS requests.
Index ¶
- type AppContext
- func (ctx *AppContext) AccessControl(h http.Handler) http.Handler
- func (ctx *AppContext) Authorization(h http.Handler) http.Handler
- func (ctx *AppContext) Logger(h http.Handler) http.Handler
- func (ctx *AppContext) OptionsHandler(h http.Handler) http.Handler
- func (ctx *AppContext) StartAppContext(h http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppContext ¶
AppContext holds context data for the application. This can hold information such as a database connection, session data, user info, and more. Your middlewares should attach functions to this structure to pass critical data to request handlers.
func (*AppContext) AccessControl ¶
func (ctx *AppContext) AccessControl(h http.Handler) http.Handler
AccessControl is a middleware that tells a browser abour CORS, allowed verbs, and accepted headers. Modify this to change these security features.
func (*AppContext) Authorization ¶
func (ctx *AppContext) Authorization(h http.Handler) http.Handler
Authorization is a middleware for handling authorization of requests. Here is where you might authorize a token, user session, or cookie.
func (*AppContext) Logger ¶
func (ctx *AppContext) Logger(h http.Handler) http.Handler
Logger is a middleware which logs requests to the console. It also includes the time it takes for the request to complete.
func (*AppContext) OptionsHandler ¶
func (ctx *AppContext) OptionsHandler(h http.Handler) http.Handler
OptionsHandler is a middleware for handling OPTIONS requests.
func (*AppContext) StartAppContext ¶
func (ctx *AppContext) StartAppContext(h http.Handler) http.Handler
StartAppContext is a middleware that should be early in the chain. This sets up the initial context and attaches important data to the Gorilla Context which comes across in the request.