Documentation ¶
Index ¶
- type ChainLink
- type Composer
- func (composer *Composer) BuildRoutes() Routes
- func (composer *Composer) Delete(pattern string, handler http.Handler)
- func (composer *Composer) EachRoute(router func(*Route))
- func (composer *Composer) Get(pattern string, handler http.Handler)
- func (composer *Composer) Handle(method string, pattern string, handler http.Handler)
- func (composer *Composer) Only() *RouteConstraint
- func (composer *Composer) Patch(pattern string, handler http.Handler)
- func (composer *Composer) Post(pattern string, handler http.Handler)
- func (composer *Composer) Put(pattern string, handler http.Handler)
- func (composer *Composer) Sub(pattern string, sub func(*Composer))
- func (composer *Composer) Use() *MiddlewareOptions
- type MiddlewareOptions
- type Route
- type RouteConstraint
- func (rc *RouteConstraint) Delete() *RouteConstraint
- func (rc *RouteConstraint) Get() *RouteConstraint
- func (rc *RouteConstraint) Patch() *RouteConstraint
- func (rc *RouteConstraint) Post() *RouteConstraint
- func (rc *RouteConstraint) Put() *RouteConstraint
- func (rc *RouteConstraint) Use() *MiddlewareOptions
- func (rc *RouteConstraint) When(condition func() bool) *RouteConstraint
- func (rc *RouteConstraint) WhenRouteMatches(routeFilter func(*RouteModel) bool) *RouteConstraint
- type RouteModel
- type Routes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainLink ¶
ChainLink is used when your http.Handler needs to wrap the rest of the handler chain.
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer is the main API in gonion and is responsible for composing the middleware and routes of your application
func (*Composer) BuildRoutes ¶
BuildRoutes returns routes with their corresponding handler chain. This is typically what you will call before delegating to the router you have chosen for your application.
func (*Composer) EachRoute ¶
EachRoute is a convenience method for BuildRoutes that you can pass a func to be called on each route from BuildRoutes.
func (*Composer) Only ¶
func (composer *Composer) Only() *RouteConstraint
Only allows you to constrain middleware for only certain types of routes. This isn't just a runtime filter, it excludes it from the chain while building the routes on startup.
func (*Composer) Sub ¶
Sub will allow you to specify middleware and routes that only apply for the specified path. This can be done recursively and at each level will inherit the previous path's middleware.
func (*Composer) Use ¶
func (composer *Composer) Use() *MiddlewareOptions
Use is the entrypoint to adding middleware
type MiddlewareOptions ¶
type MiddlewareOptions struct {
// contains filtered or unexported fields
}
MiddlewareOptions is accessed from calling Use() and is how you specify which way to register a middleware handler.
func (*MiddlewareOptions) ChainLink ¶
func (mo *MiddlewareOptions) ChainLink(ctor func(http.Handler) http.Handler)
ChainLink is called when your middleware handler needs to wrap the rest of the handler chain.
func (*MiddlewareOptions) Func ¶
func (mo *MiddlewareOptions) Func(handler func(http.ResponseWriter, *http.Request))
Func is a convenience method for a func that matches the signature of the standard http.HandlerFunc.
func (*MiddlewareOptions) Handler ¶
func (mo *MiddlewareOptions) Handler(handler http.Handler)
Handler is middleware that conforms to the standard http.Handler interface
type Route ¶
Route is the handler and route information after calling BuildRoutes. Handler is the entire chain of route handler and middleware.
type RouteConstraint ¶
type RouteConstraint struct {
// contains filtered or unexported fields
}
RouteConstraint is how middleware is constrained after calling Only()
func (*RouteConstraint) Delete ¶
func (rc *RouteConstraint) Delete() *RouteConstraint
Delete constrains the middleware to only apply for 'DELETE' requests
func (*RouteConstraint) Get ¶
func (rc *RouteConstraint) Get() *RouteConstraint
Get constrains the middleware to only apply for 'GET' requests
func (*RouteConstraint) Patch ¶
func (rc *RouteConstraint) Patch() *RouteConstraint
Patch constrains the middleware to only apply for 'PATCH' requests
func (*RouteConstraint) Post ¶
func (rc *RouteConstraint) Post() *RouteConstraint
Post constrains the middleware to only apply for 'POST' requests
func (*RouteConstraint) Put ¶
func (rc *RouteConstraint) Put() *RouteConstraint
Put constrains the middleware to only apply for 'PUT' requests
func (*RouteConstraint) Use ¶
func (rc *RouteConstraint) Use() *MiddlewareOptions
Use is the entrypoint to defining your middleware, but only for the current defined route constraint
func (*RouteConstraint) When ¶
func (rc *RouteConstraint) When(condition func() bool) *RouteConstraint
When is a constraint that gives you the option to only apply upon a condition being true
func (*RouteConstraint) WhenRouteMatches ¶
func (rc *RouteConstraint) WhenRouteMatches(routeFilter func(*RouteModel) bool) *RouteConstraint
WhenRouteMatches is a constraint that gives you all the route information to filter upon.
type RouteModel ¶
RouteModel is the pre-build model representing a single handler without middleware.