service

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2019 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Index

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

func DeleteEndpoint(route string, handlers ...httpx.Handler) Endpoint

DeleteEndpoint returns an Endpoint configured for the given route with the DELETE pipeline using the given handlers.

func DeleteEndpointWithPolicy added in v0.3.0

func DeleteEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint

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

func GetEndpoint(route string, handlers ...httpx.Handler) Endpoint

GetEndpoint returns an Endpoint configured for the given route with the GET pipeline using the given handlers.

func GetEndpointWithPolicy added in v0.3.0

func GetEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint

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

func PatchEndpoint(route string, handlers ...httpx.Handler) Endpoint

PatchEndpoint returns an Endpoint configured for the given route with the PATCH pipeline using the given handlers.

func PatchEndpointWithPolicy added in v0.3.0

func PatchEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint

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

func PostEndpoint(route string, handlers ...httpx.Handler) Endpoint

PostEndpoint returns an Endpoint configured for the given route with the POST pipeline using the given handlers.

func PostEndpointWithPolicy added in v0.3.0

func PostEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint

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

func PutEndpoint(route string, handlers ...httpx.Handler) Endpoint

PutEndpoint returns an Endpoint configured for the given route with the PUT pipeline using the given handlers.

func PutEndpointWithPolicy added in v0.3.0

func PutEndpointWithPolicy(route string, policy Policy, handlers ...httpx.Handler) Endpoint

PutEndpointWithPolicy returns an Endpoint configured for the given route, with the given policy and the PUT pipeline using the given handlers.

func (Endpoint) String added in v0.3.0

func (e Endpoint) String() string

String implements `expvar.Var.String`

type Pipeline

type Pipeline struct {
	Policy       Policy                  // customizes automated behavior
	Handlers     []httpx.Handler         // the pipline steps, minimum one
	QuerySchemas []httpx.ParameterSchema // 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL