Documentation
¶
Index ¶
- type Endpoint
- func DeleteEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func DeleteEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func GetEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func GetEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func PatchEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func PatchEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func PostEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func PostEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- func PutEndpoint(route string, handlers ...httpx.Handler) Endpoint
- func PutEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint
- type Pipeline
- type Policy
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
Route string // the absolute URL path for this endpoint
Head *Pipeline // HEAD method pipeline
Get *Pipeline // GET method pipeline
Put *Pipeline // PUT method pipeline
Post *Pipeline // POST method pipeline
Patch *Pipeline // PATCH method pipeline
Delete *Pipeline // DELETE method pipeline
Connect *Pipeline // CONNECT method pipeline
Options *Pipeline // OPTIONS method pipeline
Trace *Pipeline // TRACE method pipeline
}
Endpoint is collection of pipelines for a route (URL path), one for each HTTP method. Only supported methods should have pipelines, but at least one pipleline is requried.
func DeleteEndpoint ¶ added in v0.3.0
DeleteEndpoint returns an Endpoint configured for the given route with the DELETE pipeline using the given handlers.
func DeleteEndpointWithPolicy ¶ added in v0.3.0
DeleteEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the DELETE pipeline using the given handlers.
func GetEndpoint ¶ added in v0.3.0
GetEndpoint returns an Endpoint configured for the given route with the GET pipeline using the given handlers.
func GetEndpointWithPolicy ¶ added in v0.3.0
GetEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the GET pipeline using the given handlers.
func PatchEndpoint ¶ added in v0.3.0
PatchEndpoint returns an Endpoint configured for the given route with the PATCH pipeline using the given handlers.
func PatchEndpointWithPolicy ¶ added in v0.3.0
PatchEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the PATCH pipeline using the given handlers.
func PostEndpoint ¶ added in v0.3.0
PostEndpoint returns an Endpoint configured for the given route with the POST pipeline using the given handlers.
func PostEndpointWithPolicy ¶ added in v0.3.0
PostEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the POST pipeline using the given handlers.
func PutEndpoint ¶ added in v0.3.0
PutEndpoint returns an Endpoint configured for the given route with the PUT pipeline using the given handlers.
func PutEndpointWithPolicy ¶ added in v0.3.0
PutEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the PUT pipeline using the given handlers.
type Pipeline ¶
type Pipeline struct {
Policy Policy // customizes automated behavior
Handlers []httpx.Handler // the pipline steps, minimum one
QueryFields []httpx.Field // optional query parameter validation
}
Pipeline is a chain of handlers to be invoked in order on a request. The first non-nil response will be returned to the user agent. If no response is produced an Internal Service Error handler will be invoked.
type Policy ¶
type Policy struct {
// Will malformed query parameters be passed through or
// rejected?
AllowMalformedQueryParameters bool `json:",omitempty"`
// Will unknown query parameters be passed through or
// rejected?
AllowUnknownQueryParameters bool `json:",omitempty"`
// Will requests with missing/extra trailing slash
// be redirected?
AllowTrailingSlashRedirects bool `json:",omitempty"`
// Will URL escaped path parameters be preserved?
PreserveEscapedPathParameters bool `json:",omitempty"`
// The time budget for the pipeline to complete
TimeBudget time.Duration `json:",omitempty"`
}
Policy controls the behavior of per-endpoint request processing before control is passed to the handler.
type Service ¶
type Service struct {
Name string // Service name. Required.
Endpoints []Endpoint // Service endpoints. Requried.
// Handlers are optional handlers that should be invoked for
// all endpoints. These will be prepended to all endpoint
// handlers when a service is registered.
Handlers []httpx.Handler
// MalformedRequestHandler optionally customizes the
// response to the user agent when a malformed request is
// presented.
// If nil the default handler wil return a 400 status code
// with an empty body.
MalformedRequestHandler httpx.Handler
// MethodNotAllowedHandler optionally customizes the response
// returned to the user agent when an endpoint isn't
// configured to service the method of a request.
// If nil the default handler will return a 405 status code
// with an empty body.
MethodNotAllowedHandler httpx.Handler
// RedirectHandler optionally customizes the response
// returned to the user agent when an endpoint is configured
// to return a redirect for a path based on a missing or
// extra trailing slash.
// If nil the default handler will return a 303 status code
// for GET and a 307 for other methods, both with an empty
// body.
RedirectHandler httpx.Handler
// InternalServerErrorHandler optionally customizes the
// response returned to the user agent when the gateway
// encounters an error trying to service a request to an
// endoint of this service.
// If nil the default handler will return a 500 status code
// with an empty body.
InternalServerErrorHandler httpx.ErrorHandler
}
Service is a logical grouping of related endpoints. Examples of relationships are serving the same product vertical or requiring the same resources. This is an interface instead of a struct so that implementations can store dependencies in the struct.