Documentation ¶
Overview ¶
Package http provides an HTTP component with included observability.
Index ¶
- Constants
- Variables
- func ExtractParams(r *http.Request) map[string]string
- type AliveCheckFuncdeprecated
- type AliveStatusdeprecated
- type Builderdeprecated
- func NewBuilder() *Builderdeprecated
- func (cb *Builder) Create() (*Component, error)
- func (cb *Builder) WithAliveCheckFunc(acf AliveCheckFunc) *Builder
- func (cb *Builder) WithDeflateLevel(level int) *Builder
- func (cb *Builder) WithMiddlewares(mm ...middleware.Func) *Builder
- func (cb *Builder) WithPort(p int) *Builder
- func (cb *Builder) WithReadTimeout(rt time.Duration) *Builder
- func (cb *Builder) WithReadyCheckFunc(rcf ReadyCheckFunc) *Builder
- func (cb *Builder) WithRoutesBuilder(rb *RoutesBuilder) *Builder
- func (cb *Builder) WithSSL(c, k string) *Builder
- func (cb *Builder) WithShutdownGracePeriod(gp time.Duration) *Builder
- func (cb *Builder) WithUncompressedPaths(r ...string) *Builder
- func (cb *Builder) WithWriteTimeout(wt time.Duration) *Builder
- type Componentdeprecated
- type Errordeprecated
- func NewError() *Errordeprecated
- func NewErrorWithCodeAndPayload(code int, payload interface{}) *Errordeprecated
- func NewForbiddenError() *Errordeprecated
- func NewForbiddenErrorWithPayload(payload interface{}) *Errordeprecated
- func NewNotFoundError() *Errordeprecated
- func NewNotFoundErrorWithPayload(payload interface{}) *Errordeprecated
- func NewServiceUnavailableError() *Errordeprecated
- func NewServiceUnavailableErrorWithPayload(payload interface{}) *Errordeprecated
- func NewUnauthorizedError() *Errordeprecated
- func NewUnauthorizedErrorWithPayload(payload interface{}) *Errordeprecated
- func NewValidationError() *Errordeprecated
- func NewValidationErrorWithPayload(payload interface{}) *Errordeprecated
- type Headerdeprecated
- type ProcessorFuncdeprecated
- type ReadyCheckFuncdeprecated
- type ReadyStatusdeprecated
- type Requestdeprecated
- type Responsedeprecated
- type Route
- type RouteBuilderdeprecated
- func NewConnectRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewDeleteRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewFileServer(path string, assetsDir string, fallbackPath string) *RouteBuilderdeprecated
- func NewGetRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewHeadRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewOptionsRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewPatchRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewPostRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewPutRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewRawRouteBuilder(path string, handler http.HandlerFunc) *RouteBuilderdeprecated
- func NewRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func NewTraceRouteBuilder(path string, processor ProcessorFunc) *RouteBuilderdeprecated
- func (rb *RouteBuilder) Build() (Route, error)
- func (rb *RouteBuilder) MethodConnect() *RouteBuilder
- func (rb *RouteBuilder) MethodDelete() *RouteBuilder
- func (rb *RouteBuilder) MethodGet() *RouteBuilder
- func (rb *RouteBuilder) MethodHead() *RouteBuilder
- func (rb *RouteBuilder) MethodOptions() *RouteBuilder
- func (rb *RouteBuilder) MethodPatch() *RouteBuilder
- func (rb *RouteBuilder) MethodPost() *RouteBuilder
- func (rb *RouteBuilder) MethodPut() *RouteBuilder
- func (rb *RouteBuilder) MethodTrace() *RouteBuilder
- func (rb *RouteBuilder) WithAuth(auth auth.Authenticator) *RouteBuilder
- func (rb *RouteBuilder) WithMiddlewares(mm ...middleware.Func) *RouteBuilder
- func (rb *RouteBuilder) WithRateLimiting(limit float64, burst int) *RouteBuilder
- func (rb *RouteBuilder) WithRouteCache(cache cache.TTLCache, ageBounds httpcache.Age) *RouteBuilder
- func (rb *RouteBuilder) WithTrace() *RouteBuilder
- type RoutesBuilderdeprecated
- func NewRoutesBuilder() *RoutesBuilderdeprecated
Constants ¶
const MetricsPath = "/metrics"
MetricsPath definition.
Variables ¶
var ( // DefaultAliveCheck return always live. // // Deprecated: Please use the new v2 package. // This package is frozen and no new functionality will be added. DefaultAliveCheck = func() AliveStatus { return Alive } // DefaultReadyCheck return always ready. // // Deprecated: Please use the new v2 package. // This package is frozen and no new functionality will be added. DefaultReadyCheck = func() ReadyStatus { return Ready } )
Functions ¶
Types ¶
type AliveCheckFunc
deprecated
type AliveCheckFunc func() AliveStatus
AliveCheckFunc defines a function type for implementing a liveness check.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
type AliveStatus
deprecated
type AliveStatus int
AliveStatus type representing the liveness of the service via HTTP component.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
const ( // Alive represents a state defining an Alive state. Alive AliveStatus = 1 // Unresponsive represents a state defining a Unresponsive state. Unresponsive AliveStatus = 2 // AlivePath of the service. AlivePath = "/alive" )
type Builder
deprecated
type Builder struct {
// contains filtered or unexported fields
}
Builder gathers all required and optional properties, in order to construct an HTTP component.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewBuilder
deprecated
func NewBuilder() *Builder
NewBuilder initiates the HTTP component builder chain. The builder instantiates the component using default values for HTTP Port, Alive/Ready check functions and Read/Write timeouts.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func (*Builder) WithAliveCheckFunc ¶
func (cb *Builder) WithAliveCheckFunc(acf AliveCheckFunc) *Builder
WithAliveCheckFunc sets the AliveCheckFunc used by the HTTP component.
func (*Builder) WithDeflateLevel ¶ added in v0.49.0
WithDeflateLevel sets the level of compression for Deflate; based on https://golang.org/pkg/compress/flate/ Levels range from 1 (BestSpeed) to 9 (BestCompression); higher levels typically run slower but compress more. Level 0 (NoCompression) does not attempt any compression; it only adds the necessary DEFLATE framing. Level -1 (DefaultCompression) uses the default compression level. Level -2 (HuffmanOnly) will use Huffman compression only, giving a very fast compression for all types of input, but sacrificing considerable compression efficiency.
func (*Builder) WithMiddlewares ¶
func (cb *Builder) WithMiddlewares(mm ...middleware.Func) *Builder
WithMiddlewares adds middlewares to the HTTP component.
func (*Builder) WithReadTimeout ¶
WithReadTimeout sets the Read Timeout for the HTTP component.
func (*Builder) WithReadyCheckFunc ¶
func (cb *Builder) WithReadyCheckFunc(rcf ReadyCheckFunc) *Builder
WithReadyCheckFunc sets the ReadyCheckFunc used by the HTTP component.
func (*Builder) WithRoutesBuilder ¶
func (cb *Builder) WithRoutesBuilder(rb *RoutesBuilder) *Builder
WithRoutesBuilder adds routes builder to the HTTP component.
func (*Builder) WithSSL ¶
WithSSL sets the filenames for the Certificate and Keyfile, in order to enable SSL.
func (*Builder) WithShutdownGracePeriod ¶ added in v0.43.1
WithShutdownGracePeriod sets the Shutdown Grace Period for the HTTP component.
func (*Builder) WithUncompressedPaths ¶ added in v0.49.0
WithUncompressedPaths specifies which routes should be excluded from compression Any trailing slashes are trimmed, so we match both /metrics/ and /metrics?seconds=30.
type Component
deprecated
Component implementation of HTTP.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
type Error
deprecated
type Error struct {
// contains filtered or unexported fields
}
Error defines an abstract struct that can represent several types of HTTP errors.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewErrorWithCodeAndPayload
deprecated
func NewForbiddenError
deprecated
func NewForbiddenError() *Error
NewForbiddenError creates a new forbidden error with default payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewForbiddenErrorWithPayload
deprecated
func NewForbiddenErrorWithPayload(payload interface{}) *Error
NewForbiddenErrorWithPayload creates a new forbidden error with the specified payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewNotFoundError
deprecated
func NewNotFoundError() *Error
NewNotFoundError creates a new not found error with default payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewNotFoundErrorWithPayload
deprecated
func NewNotFoundErrorWithPayload(payload interface{}) *Error
NewNotFoundErrorWithPayload creates a new not found error with the specified payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewServiceUnavailableError
deprecated
func NewServiceUnavailableError() *Error
NewServiceUnavailableError creates a new service unavailable error with default payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewServiceUnavailableErrorWithPayload
deprecated
func NewServiceUnavailableErrorWithPayload(payload interface{}) *Error
NewServiceUnavailableErrorWithPayload creates a new service unavailable error with the specified payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewUnauthorizedError
deprecated
func NewUnauthorizedError() *Error
NewUnauthorizedError creates a new validation error with default payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewUnauthorizedErrorWithPayload
deprecated
func NewUnauthorizedErrorWithPayload(payload interface{}) *Error
NewUnauthorizedErrorWithPayload creates a new unauthorized error with the specified payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewValidationError
deprecated
func NewValidationError() *Error
NewValidationError creates a new validation error with default payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewValidationErrorWithPayload
deprecated
func NewValidationErrorWithPayload(payload interface{}) *Error
NewValidationErrorWithPayload creates a new validation error with the specified payload.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
type ReadyCheckFunc
deprecated
type ReadyCheckFunc func() ReadyStatus
ReadyCheckFunc defines a function type for implementing a readiness check.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
type ReadyStatus
deprecated
type ReadyStatus int
ReadyStatus type.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
const ( // Ready represents a state defining a Ready state. Ready ReadyStatus = 1 // NotReady represents a state defining a NotReady state. NotReady ReadyStatus = 2 // ReadyPath of the service. ReadyPath = "/ready" )
type Request
deprecated
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route definition of an HTTP route.
func (Route) Handler ¶ added in v0.40.1
func (r Route) Handler() http.HandlerFunc
Handler returns route handler function.
func (Route) Middlewares ¶ added in v0.40.1
func (r Route) Middlewares() []middleware.Func
Middlewares returns route middlewares.
type RouteBuilder
deprecated
type RouteBuilder struct {
// contains filtered or unexported fields
}
RouteBuilder for building a route.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewConnectRouteBuilder
deprecated
added in
v0.47.0
func NewConnectRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewConnectRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewDeleteRouteBuilder
deprecated
added in
v0.47.0
func NewDeleteRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewDeleteRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewFileServer
deprecated
added in
v0.54.0
func NewFileServer(path string, assetsDir string, fallbackPath string) *RouteBuilder
NewFileServer constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewGetRouteBuilder
deprecated
added in
v0.47.0
func NewGetRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewGetRouteBuilder constructor
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewHeadRouteBuilder
deprecated
added in
v0.47.0
func NewHeadRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewHeadRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewOptionsRouteBuilder
deprecated
added in
v0.47.0
func NewOptionsRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewOptionsRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewPatchRouteBuilder
deprecated
added in
v0.47.0
func NewPatchRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewPatchRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewPostRouteBuilder
deprecated
added in
v0.47.0
func NewPostRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewPostRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewPutRouteBuilder
deprecated
added in
v0.47.0
func NewPutRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewPutRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewRawRouteBuilder
deprecated
func NewRawRouteBuilder(path string, handler http.HandlerFunc) *RouteBuilder
NewRawRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewRouteBuilder
deprecated
func NewRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewTraceRouteBuilder
deprecated
added in
v0.47.0
func NewTraceRouteBuilder(path string, processor ProcessorFunc) *RouteBuilder
NewTraceRouteBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func (*RouteBuilder) MethodConnect ¶
func (rb *RouteBuilder) MethodConnect() *RouteBuilder
MethodConnect HTTP method.
func (*RouteBuilder) MethodDelete ¶
func (rb *RouteBuilder) MethodDelete() *RouteBuilder
MethodDelete HTTP method.
func (*RouteBuilder) MethodGet ¶
func (rb *RouteBuilder) MethodGet() *RouteBuilder
MethodGet HTTP method.
func (*RouteBuilder) MethodHead ¶
func (rb *RouteBuilder) MethodHead() *RouteBuilder
MethodHead HTTP method.
func (*RouteBuilder) MethodOptions ¶
func (rb *RouteBuilder) MethodOptions() *RouteBuilder
MethodOptions HTTP method.
func (*RouteBuilder) MethodPatch ¶
func (rb *RouteBuilder) MethodPatch() *RouteBuilder
MethodPatch HTTP method.
func (*RouteBuilder) MethodPost ¶
func (rb *RouteBuilder) MethodPost() *RouteBuilder
MethodPost HTTP method.
func (*RouteBuilder) MethodPut ¶
func (rb *RouteBuilder) MethodPut() *RouteBuilder
MethodPut HTTP method.
func (*RouteBuilder) MethodTrace ¶
func (rb *RouteBuilder) MethodTrace() *RouteBuilder
MethodTrace HTTP method.
func (*RouteBuilder) WithAuth ¶
func (rb *RouteBuilder) WithAuth(auth auth.Authenticator) *RouteBuilder
WithAuth adds authenticator.
func (*RouteBuilder) WithMiddlewares ¶
func (rb *RouteBuilder) WithMiddlewares(mm ...middleware.Func) *RouteBuilder
WithMiddlewares adds middlewares.
func (*RouteBuilder) WithRateLimiting ¶ added in v0.51.0
func (rb *RouteBuilder) WithRateLimiting(limit float64, burst int) *RouteBuilder
WithRateLimiting enables route rate limiting.
func (*RouteBuilder) WithRouteCache ¶ added in v0.43.0
func (rb *RouteBuilder) WithRouteCache(cache cache.TTLCache, ageBounds httpcache.Age) *RouteBuilder
WithRouteCache adds a cache to the corresponding route.
func (*RouteBuilder) WithTrace ¶
func (rb *RouteBuilder) WithTrace() *RouteBuilder
WithTrace enables route tracing that uses Jaeger/OpenTracing. It requires Jaeger enabled on the Patron service.
type RoutesBuilder
deprecated
type RoutesBuilder struct {
// contains filtered or unexported fields
}
RoutesBuilder creates a list of routes.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func NewRoutesBuilder
deprecated
func NewRoutesBuilder() *RoutesBuilder
NewRoutesBuilder constructor.
Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.
func (*RoutesBuilder) Append ¶
func (rb *RoutesBuilder) Append(builder *RouteBuilder) *RoutesBuilder
Append a route to the list.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package auth provides abstractions for concrete implementations.
|
Package auth provides abstractions for concrete implementations. |
apikey
Package apikey is a concrete implementation of the auth abstractions.
|
Package apikey is a concrete implementation of the auth abstractions. |
Package cache provides a cache control and implementation components for http routes.
|
Package cache provides a cache control and implementation components for http routes. |
Package v2 provides a ready to use HTTP component.
|
Package v2 provides a ready to use HTTP component. |