Documentation ¶
Overview ¶
Package v2 provides a ready to use HTTP component.
Index ¶
- Constants
- type AliveStatus
- type Component
- type LivenessCheckFunc
- type OptionFunc
- type ReadyCheckFunc
- type ReadyStatus
- type Route
- func LivenessCheckRoute(acf LivenessCheckFunc) (*Route, error)
- func MetricRoute() *Route
- func NewConnectRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewDeleteRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewGetRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewHeadRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewOptionsRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewPatchRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewPostRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewPutRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewRoute(method, path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func NewTraceRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
- func ProfilingRoutes(enableExpVar bool) []*Route
- func ReadyCheckRoute(rcf ReadyCheckFunc) (*Route, error)
- type RouteOptionFunc
- type Routes
Constants ¶
const ( // Alive represents a state defining an Alive state. Alive AliveStatus = 1 // Unhealthy represents an unhealthy alive state. Unhealthy AliveStatus = 2 // Ready represents a state defining a Ready state. Ready ReadyStatus = 1 // NotReady represents a state defining a NotReady state. NotReady ReadyStatus = 2 // AlivePath of the component. AlivePath = "/alive" // ReadyPath of the component. ReadyPath = "/ready" )
const (
// MetricsPath of the component.
MetricsPath = "/metrics"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AliveStatus ¶
type AliveStatus int
AliveStatus type representing the liveness of the service via HTTP component.
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implementation of an HTTP router.
type LivenessCheckFunc ¶
type LivenessCheckFunc func() AliveStatus
LivenessCheckFunc defines a function type for implementing a liveness check.
type OptionFunc ¶
OptionFunc definition for configuring the component in a functional way.
func HandlerTimeout ¶
func HandlerTimeout(wt time.Duration) OptionFunc
HandlerTimeout functional option.
func ShutdownGracePeriod ¶
func ShutdownGracePeriod(gp time.Duration) OptionFunc
ShutdownGracePeriod functional option.
type ReadyCheckFunc ¶
type ReadyCheckFunc func() ReadyStatus
ReadyCheckFunc defines a function type for implementing a readiness check.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route definition of an HTTP route.
func LivenessCheckRoute ¶
func LivenessCheckRoute(acf LivenessCheckFunc) (*Route, error)
LivenessCheckRoute returns a route for liveness checks.
func NewConnectRoute ¶
func NewConnectRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewConnectRoute constructor.
func NewDeleteRoute ¶
func NewDeleteRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewDeleteRoute constructor.
func NewGetRoute ¶
func NewGetRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewGetRoute constructor.
func NewHeadRoute ¶
func NewHeadRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewHeadRoute constructor.
func NewOptionsRoute ¶
func NewOptionsRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewOptionsRoute constructor.
func NewPatchRoute ¶
func NewPatchRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewPatchRoute constructor.
func NewPostRoute ¶
func NewPostRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewPostRoute constructor.
func NewPutRoute ¶
func NewPutRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewPutRoute constructor.
func NewRoute ¶
func NewRoute(method, path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewRoute creates a new raw route with functional configuration.
func NewTraceRoute ¶
func NewTraceRoute(path string, handler http.HandlerFunc, oo ...RouteOptionFunc) (*Route, error)
NewTraceRoute constructor.
func ProfilingRoutes ¶
func ReadyCheckRoute ¶
func ReadyCheckRoute(rcf ReadyCheckFunc) (*Route, error)
ReadyCheckRoute returns a route for ready checks.
func (Route) Handler ¶
func (r Route) Handler() http.HandlerFunc
func (Route) Middlewares ¶
func (r Route) Middlewares() []patronhttp.Func
type RouteOptionFunc ¶
RouteOptionFunc definition for configuring the route in a functional way.
func Auth ¶
func Auth(auth auth.Authenticator) RouteOptionFunc
Auth option for setting the route auth.
func Cache ¶
func Cache(cache cache.TTLCache, ageBounds httpcache.Age) RouteOptionFunc
Cache option for setting the route cache.
func Middlewares ¶
func Middlewares(mm ...patronhttp.Func) RouteOptionFunc
Middlewares option for setting the route optionFuncs.
func RateLimiting ¶
func RateLimiting(limit float64, burst int) RouteOptionFunc
RateLimiting option for setting a route rate limiter.