Documentation
¶
Index ¶
- func Go[Q any, R any](h RouteHandler, method, endpoint string, ...)
- func MethodNotAllowedHandler(w http.ResponseWriter, _ *http.Request)
- func NotFoundHandler(w http.ResponseWriter, _ *http.Request)
- func Parse(w http.ResponseWriter, r *http.Request, v interface{}) error
- func ParseHeaders(r *http.Request, v interface{})
- func ParsePath(r *http.Request, v interface{}) error
- func ParseQuery(r *http.Request, v interface{}) error
- func Send(w http.ResponseWriter, r *http.Request, raw interface{})
- type CORSMiddleware
- type Middleware
- type MiddlewareFunc
- type Proxy
- type RouteHandler
- type Router
- type RouterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶ added in v0.3.0
func Go[Q any, R any](h RouteHandler, method, endpoint string, fn func(context.Context, Q) (R, error), middlewares ...Middleware)
Go handle a http request
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler(w http.ResponseWriter, _ *http.Request)
MethodNotAllowedHandler is a custom handler for method not allowed requests
func NotFoundHandler ¶
func NotFoundHandler(w http.ResponseWriter, _ *http.Request)
NotFoundHandler is a custom handler for not found requests
func Parse ¶ added in v0.0.38
func Parse(w http.ResponseWriter, r *http.Request, v interface{}) error
Parse is a method to decode a http request into a value schema struct tags are supported
func ParseHeaders ¶ added in v0.2.7
ParseHeaders decode http request headers
func ParseQuery ¶ added in v0.2.7
ParseQuery decode http query
Types ¶
type CORSMiddleware ¶
type CORSMiddleware struct {
// contains filtered or unexported fields
}
CORSMiddleware is an implementation of the CORS middleware providing method, origin, and credential allowance
func NewCORSMiddleware ¶
func NewCORSMiddleware() CORSMiddleware
NewCORSMiddleware constructs a new middleware that handles CORS
type Middleware ¶
Middleware represents a handler that is called to for example, modify request/response before or after the principal handler is called. Each Middleware is responsible for calling the next middleware in the chain (or not if continued execution is not desired)
type MiddlewareFunc ¶
MiddlewareFunc handles http middleware requests
type Proxy ¶ added in v0.0.38
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a multi-host reverse proxy
func (*Proxy) Direct ¶ added in v0.0.38
Direct sets a new director for the path e.g., pathPrefix is typically the name of the microservice
func (*Proxy) Middleware ¶ added in v0.0.38
func (p *Proxy) Middleware(middlewares ...Middleware)
Middleware adds a middleware to the proxy
type RouteHandler ¶ added in v0.2.5
type RouteHandler interface {
Route(method, endpoint string, handlerFunc http.HandlerFunc, middlewares ...Middleware)
}
RouteHandler a handler for routing http requests
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is an instance of a mux based Router
func NewRouter ¶
func NewRouter(major int, version string, opts ...RouterOption) *Router
NewRouter constructs a new mux based Router
func (*Router) Middleware ¶
func (r *Router) Middleware(middlewares ...Middleware)
Middleware adds a handler to execute before/after the principle request handler
func (*Router) Route ¶ added in v0.0.36
func (r *Router) Route(method, endpoint string, handlerFunc http.HandlerFunc, middlewares ...Middleware)
Route adds a handler for the http method and endpoint
type RouterOption ¶ added in v0.2.0
type RouterOption func(r *Router)
RouterOption is a handler for configuring the router
func WithServicePrefix ¶ added in v0.2.0
func WithServicePrefix(prefix string) RouterOption
WithServicePrefix creates a service prefix option