Documentation ¶
Index ¶
- Variables
- func DefaultMiddleware(path string, next http.HandlerFunc) http.HandlerFunc
- func RecoveryMiddleware(next http.HandlerFunc) http.HandlerFunc
- func TracingMiddleware(path string, next http.HandlerFunc) http.HandlerFunc
- type Component
- type HealthCheckFunc
- type HealthStatus
- type OptionFunc
- type Route
- func NewDeleteRoute(p string, pr sync.ProcessorFunc, trace bool) Route
- func NewGetRoute(p string, pr sync.ProcessorFunc, trace bool) Route
- func NewPostRoute(p string, pr sync.ProcessorFunc, trace bool) Route
- func NewPutRoute(p string, pr sync.ProcessorFunc, trace bool) Route
- func NewRoute(p string, m string, pr sync.ProcessorFunc, trace bool) Route
- func NewRouteRaw(p string, m string, h http.HandlerFunc) Route
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultHealthCheck returns always healthy. DefaultHealthCheck = func() HealthStatus { return Healthy } )
Functions ¶
func DefaultMiddleware ¶
func DefaultMiddleware(path string, next http.HandlerFunc) http.HandlerFunc
DefaultMiddleware which handles tracing and recovery.
func RecoveryMiddleware ¶
func RecoveryMiddleware(next http.HandlerFunc) http.HandlerFunc
RecoveryMiddleware for recovering from failed requests.
func TracingMiddleware ¶ added in v0.3.0
func TracingMiddleware(path string, next http.HandlerFunc) http.HandlerFunc
TracingMiddleware for handling tracing and metrics.
Types ¶
type Component ¶ added in v0.2.0
type Component struct {
// contains filtered or unexported fields
}
Component implementation of HTTP.
type HealthCheckFunc ¶
type HealthCheckFunc func() HealthStatus
HealthCheckFunc defines a function type for implementing a health check.
type HealthStatus ¶
type HealthStatus int
HealthStatus type representing the health of the service via HTTP component.
const ( // Initializing represents a state when warming up and before the component is Healthy. Initializing HealthStatus = 0 // Healthy represents a state defining a healthy state. Healthy HealthStatus = 1 // Unhealthy represents a state defining a unhealthy state. Unhealthy HealthStatus = 2 )
type OptionFunc ¶ added in v0.4.0
OptionFunc defines a option func for the HTTP component.
func HealthCheck ¶ added in v0.2.0
func HealthCheck(hcf HealthCheckFunc) OptionFunc
HealthCheck option for setting the health check function of the HTTP component.
func Port ¶ added in v0.2.0
func Port(port int) OptionFunc
Port option for setting the ports of the HTTP component.
func Routes ¶ added in v0.2.0
func Routes(rr []Route) OptionFunc
Routes option for setting the routes of the HTTP component.
func Secure ¶ added in v0.4.2
func Secure(certFile, keyFile string) OptionFunc
Secure option for securing the default HTTP component.
type Route ¶
type Route struct { Pattern string Method string Handler http.HandlerFunc Trace bool }
Route definition of a HTTP route.
func NewDeleteRoute ¶ added in v0.4.2
func NewDeleteRoute(p string, pr sync.ProcessorFunc, trace bool) Route
NewDeleteRoute creates a new DELETE route from a generic handler.
func NewGetRoute ¶ added in v0.4.2
func NewGetRoute(p string, pr sync.ProcessorFunc, trace bool) Route
NewGetRoute creates a new GET route from a generic handler.
func NewPostRoute ¶ added in v0.4.2
func NewPostRoute(p string, pr sync.ProcessorFunc, trace bool) Route
NewPostRoute creates a new POST route from a generic handler.
func NewPutRoute ¶ added in v0.4.2
func NewPutRoute(p string, pr sync.ProcessorFunc, trace bool) Route
NewPutRoute creates a new PUT route from a generic handler.
func NewRouteRaw ¶ added in v0.2.0
func NewRouteRaw(p string, m string, h http.HandlerFunc) Route
NewRouteRaw creates a new route from a HTTP handler.