server

package
v0.21.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 6 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternal is an internal server error.
	ErrInternal = errors.Wrap(errors.ErrInternal, "server")

	// ErrServer is an error related with server.
	ErrServer = errors.New("server")
	// ErrServerOptions is an error related with server options.
	ErrServerOptions = errors.Wrap(ErrServer, "options")
	// ErrURIParameter is an error related with uri parameters.
	ErrURIParameter = errors.Wrap(ErrServer, "uri parameter")
	// ErrServerClosed is an error thrown when the server is closed.
	ErrServerClosed = errors.Wrap(ErrServer, "closed")

	// ErrHeader errors.Minor
	ErrHeader = errors.Wrap(ErrServer, "header")
	// ErrHeaderNotAcceptable is an error related to not acceptable request header.
	ErrHeaderNotAcceptable = errors.Wrap(ErrHeader, "not acceptable")
	// ErrUnsupportedHeader is an error related to unsupported request header.
	ErrUnsupportedHeader = errors.Wrap(ErrHeader, "unsupported")
	// ErrMissingRequiredHeader is an error related to missing required header.
	ErrMissingRequiredHeader = errors.Wrap(ErrHeader, "missing required")
	// ErrHeaderValue is an error related to request header value.
	ErrHeaderValue = errors.Wrap(ErrHeader, "value")
)

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	Path        string
	HTTPMethod  string
	QueryMethod query.Method
	ModelStruct *mapping.ModelStruct
	Relation    *mapping.StructField
	Roles       []auth.Role
}

Endpoint is a structure that represents api endpoint.

type EndpointsGetter

type EndpointsGetter interface {
	// GetEndpoints is a method that gets server endpoints after initialization process.
	GetEndpoints() []*Endpoint
}

EndpointsGetter is an interface that allows to get endpoint information.

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is a http middleware function.

type MiddlewareChain

type MiddlewareChain []Middleware

MiddlewareChain is a middleware slice type that could be used as a http.Handler.

func (MiddlewareChain) Handle

func (c MiddlewareChain) Handle(handle http.Handler) http.Handler

Handle handles the chain of middlewares for given 'handle' http.Handle.

type Server

type Server interface {
	EndpointsGetter
	// ListenAndServe starts listen and serve the requests.
	Serve() error
	// Shutdown defines gentle shutdown of the server and all it's connections.
	// The server shouldn't handle any more requests but let the remaining finish within given context.
	Shutdown(ctx context.Context) error
}

Server is the interface used

Jump to

Keyboard shortcuts

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