Documentation ¶
Index ¶
- Variables
- func Middleware(trace bool, auth auth.Authenticator, path string, next http.HandlerFunc) http.HandlerFunc
- type Component
- type Error
- func NewError() *Error
- func NewErrorWithCodeAndPayload(code int, payload interface{}) *Error
- func NewForbiddenError() *Error
- func NewForbiddenErrorWithPayload(payload interface{}) *Error
- func NewNotFoundError() *Error
- func NewNotFoundErrorWithPayload(payload interface{}) *Error
- func NewServiceUnavailableError() *Error
- func NewServiceUnavailableErrorWithPayload(payload interface{}) *Error
- func NewUnauthorizedError() *Error
- func NewUnauthorizedErrorWithPayload(payload interface{}) *Error
- func NewValidationError() *Error
- func NewValidationErrorWithPayload(payload interface{}) *Error
- type HealthCheckFunc
- type HealthStatus
- type OptionFunc
- type Route
- func NewAuthDeleteRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
- func NewAuthGetRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
- func NewAuthPostRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
- func NewAuthPutRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
- func NewAuthRouteRaw(p string, m string, h http.HandlerFunc, trace bool, auth auth.Authenticator) 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, auth auth.Authenticator) Route
- func NewRouteRaw(p string, m string, h http.HandlerFunc, trace bool) Route
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultHealthCheck returns always healthy. DefaultHealthCheck = func() HealthStatus { return Healthy } )
Functions ¶
func Middleware ¶ added in v0.9.0
func Middleware(trace bool, auth auth.Authenticator, path string, next http.HandlerFunc) http.HandlerFunc
Middleware which returns all selected middlewares.
Types ¶
type Component ¶ added in v0.2.0
Component implementation of HTTP.
type Error ¶ added in v0.13.0
type Error struct {
// contains filtered or unexported fields
}
Error defines an abstract struct that can represent several types of HTTP errors.
func NewError ¶ added in v0.13.0
func NewError() *Error
NewError creates a new error with default Internal Server Error payload.
func NewErrorWithCodeAndPayload ¶ added in v0.13.0
NewErrorWithCodeAndPayload creates a fully customizable error with the specified status code and payload.
func NewForbiddenError ¶ added in v0.13.0
func NewForbiddenError() *Error
NewForbiddenError creates a new forbidden error with default payload.
func NewForbiddenErrorWithPayload ¶ added in v0.13.0
func NewForbiddenErrorWithPayload(payload interface{}) *Error
NewForbiddenErrorWithPayload creates a new forbidden error with the specified payload.
func NewNotFoundError ¶ added in v0.13.0
func NewNotFoundError() *Error
NewNotFoundError creates a new not found error with default payload.
func NewNotFoundErrorWithPayload ¶ added in v0.13.0
func NewNotFoundErrorWithPayload(payload interface{}) *Error
NewNotFoundErrorWithPayload creates a new not found error with the specified payload.
func NewServiceUnavailableError ¶ added in v0.13.0
func NewServiceUnavailableError() *Error
NewServiceUnavailableError creates a new service unavailable error with default payload.
func NewServiceUnavailableErrorWithPayload ¶ added in v0.13.0
func NewServiceUnavailableErrorWithPayload(payload interface{}) *Error
NewServiceUnavailableErrorWithPayload creates a new service unavailable error with the specified payload.
func NewUnauthorizedError ¶ added in v0.13.0
func NewUnauthorizedError() *Error
NewUnauthorizedError creates a new validation error with default payload.
func NewUnauthorizedErrorWithPayload ¶ added in v0.13.0
func NewUnauthorizedErrorWithPayload(payload interface{}) *Error
NewUnauthorizedErrorWithPayload creates a new unauthorized error with the specified payload.
func NewValidationError ¶ added in v0.13.0
func NewValidationError() *Error
NewValidationError creates a new validation error with default payload.
func NewValidationErrorWithPayload ¶ added in v0.13.0
func NewValidationErrorWithPayload(payload interface{}) *Error
NewValidationErrorWithPayload creates a new validation error with the specified payload.
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.
func Timeouts ¶ added in v0.5.2
func Timeouts(read, write time.Duration) OptionFunc
Timeouts option for setting the timeouts of the HTTP component.
type Route ¶
type Route struct { Pattern string Method string Handler http.HandlerFunc Trace bool Auth auth.Authenticator }
Route definition of a HTTP route.
func NewAuthDeleteRoute ¶ added in v0.9.0
func NewAuthDeleteRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
NewAuthDeleteRoute creates a new DELETE route from a generic handler.
func NewAuthGetRoute ¶ added in v0.9.0
func NewAuthGetRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
NewAuthGetRoute creates a new GET route from a generic handler.
func NewAuthPostRoute ¶ added in v0.9.0
func NewAuthPostRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
NewAuthPostRoute creates a new POST route from a generic handler.
func NewAuthPutRoute ¶ added in v0.9.0
func NewAuthPutRoute(p string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
NewAuthPutRoute creates a new PUT route from a generic handler.
func NewAuthRouteRaw ¶ added in v0.9.0
func NewAuthRouteRaw(p string, m string, h http.HandlerFunc, trace bool, auth auth.Authenticator) Route
NewAuthRouteRaw creates a new route from a HTTP handler.
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 NewRoute ¶
func NewRoute(p string, m string, pr sync.ProcessorFunc, trace bool, auth auth.Authenticator) Route
NewRoute creates a new route from a generic handler.
func NewRouteRaw ¶ added in v0.2.0
NewRouteRaw creates a new route from a HTTP handler.