Documentation ¶
Index ¶
Constants ¶
const KeyValues ctxKey = 1
KeyValues is how request values or stored/retrieved.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { *httptreemux.TreeMux // contains filtered or unexported fields }
App is the entrypoint into our application and what configures our context object for each of our http handlers. Feel free to add any configuration data/logic on this App struct
func NewApp ¶
func NewApp(shutdown chan os.Signal, mw ...Middleware) *App
NewApp creates an App value that handle a set of routes for the application.
func (*App) Handle ¶
func (a *App) Handle(verb, path string, handler Handler, mw ...Middleware)
Handle is our mechanism for mounting Handlers for a given HTTP verb and path pair, this makes for really easy, convenient routing.
func (*App) ServeHTTP ¶
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface. It overrides the ServeHTTP of the embedded TreeMux by using the ochttp.Handler instead. That Handler wraps the TreeMux handler so the routes are served.
func (*App) SignalShutdown ¶
func (a *App) SignalShutdown()
SignalShutdown is used to gracefully shutdown the app when an integrity issue is identified.
type Handler ¶
type Handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error
A Handler is a type that handles an http request within our own little mini framework.
type Middleware ¶
Middleware is a function designed to run some code before and/or after another Handler. It is designed to remove boilerplate or other concerns not direct to any given Handler.