server

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: Apache-2.0 Imports: 9 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")
	// 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 AfterDeleteHandler

type AfterDeleteHandler interface {
	HandleAfterDelete(params *Params, q *query.Scope, result *codec.Payload) error
}

AfterDeleteHandler is a hook interface used to execute after API deleteQuery request.

type AfterDeleteRelationsHandler

type AfterDeleteRelationsHandler interface {
	HandleAfterDeleteRelations(params *Params, root mapping.Model, newRelations []mapping.Model, output *codec.Payload) error
}

AfterDeleteRelationsHandler is a hook interface used to execute after API delete relations request.

type AfterGetHandler

type AfterGetHandler interface {
	HandleAfterGet(params *Params, payload *codec.Payload) error
}

AfterGetHandler is the api hook after handling get query.

type AfterGetRelationHandler

type AfterGetRelationHandler interface {
	HandleAfterGetRelation(params *Params, result *codec.Payload) error
}

AfterGetRelationHandler is an interface used as a hook after API request for getting relations.

type AfterInsertHandler

type AfterInsertHandler interface {
	HandleAfterInsert(params *Params, input *codec.Payload) error
}

AfterInsertHandler is a hook handler interface after API insert query.

type AfterInsertRelationsHandler

type AfterInsertRelationsHandler interface {
	HandleAfterInsertRelations(params *Params, root mapping.Model, newRelations []mapping.Model, output *codec.Payload) error
}

AfterInsertRelationsHandler is a hook interface used to execute after API insert relations request.

type AfterListHandler

type AfterListHandler interface {
	HandleAfterList(params *Params, payload *codec.Payload) error
}

AfterListHandler is the api hook after handling list query.

type AfterUpdateHandler

type AfterUpdateHandler interface {
	HandleAfterUpdate(params *Params, input *codec.Payload) error
}

AfterUpdateHandler is a hook handler interface after API update query.

type AfterUpdateRelationsHandler

type AfterUpdateRelationsHandler interface {
	HandleAfterUpdateRelations(params *Params, root mapping.Model, newRelations []mapping.Model, output *codec.Payload) error
}

AfterUpdateRelationsHandler is a hook interface used to execute after API update relations request.

type BeforeDeleteHandler

type BeforeDeleteHandler interface {
	HandleBeforeDelete(params *Params, q *query.Scope) error
}

BeforeDeleteHandler is a hook interface used to execute before API deleteQuery request.

type BeforeDeleteRelationsHandler

type BeforeDeleteRelationsHandler interface {
	HandleBeforeDeleteRelations(params *Params, root mapping.Model, input *codec.Payload) error
}

BeforeDeleteRelationsHandler is a hook interface used to execute before API delete relations request.

type BeforeGetHandler

type BeforeGetHandler interface {
	HandleBeforeGet(params *Params, q *query.Scope) error
}

BeforeGetHandler is the api hook handler before handling the query.

type BeforeGetRelationHandler

type BeforeGetRelationHandler interface {
	HandleBeforeGetRelation(params *Params, q, relatedQuery *query.Scope, relation *mapping.StructField) error
}

BeforeGetRelationHandler is an interface used as a hook before API request for getting relations.

type BeforeInsertHandler

type BeforeInsertHandler interface {
	HandleBeforeInsert(params *Params, input *codec.Payload) error
}

BeforeInsertHandler is a hook handler interface before API insert query.

type BeforeInsertRelationsHandler

type BeforeInsertRelationsHandler interface {
	HandleBeforeInsertRelations(params *Params, root mapping.Model, input *codec.Payload) error
}

BeforeInsertRelationsHandler is a hook interface used to execute before API insert relations request.

type BeforeListHandler

type BeforeListHandler interface {
	HandleBeforeList(params *Params, q *query.Scope) error
}

BeforeListHandler is the api hook handler before handling the list query.

type BeforeUpdateHandler

type BeforeUpdateHandler interface {
	HandleBeforeUpdate(params *Params, input *codec.Payload) error
}

BeforeUpdateHandler is a hook handler interface before API update query.

type BeforeUpdateRelationsHandler

type BeforeUpdateRelationsHandler interface {
	HandleBeforeUpdateRelations(params *Params, root mapping.Model, input *codec.Payload) error
}

BeforeUpdateRelationsHandler is a hook interface used to execute before API update relations request.

type DeleteHandler

type DeleteHandler interface {
	HandleDelete(ctx context.Context, params Params, q *query.Scope) (*codec.Payload, error)
}

DeleteHandler is an interface used for handling API 'deleteQuery' requests.

type DeleteMiddlewarer

type DeleteMiddlewarer interface {
	DeleteMiddlewares() []Middleware
}

DeleteMiddlewarer is an interface that gets middlewares for the 'deleteQuery' endpoint.

type DeleteRelationsMiddlewarer

type DeleteRelationsMiddlewarer interface {
	DeleteRelationsMiddlewares() []Middleware
}

DeleteRelationsMiddlewarer is an interface that gets middlewares for the 'DeleteRelation' endpoint.

type Endpoint

type Endpoint struct {
	Path        string
	HTTPMethod  string
	QueryMethod query.Method
	ModelStruct *mapping.ModelStruct
	Relation    *mapping.StructField
}

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 GetHandler

type GetHandler interface {
	HandleGet(ctx context.Context, params Params, q *query.Scope) (*codec.Payload, error)
}

GetHandler is the handler used to get the model

type GetMiddlewarer

type GetMiddlewarer interface {
	GetMiddlewares() []Middleware
}

GetMiddlewarer is an interface that gets middlewares for the 'Get' endpoint.

type GetRelationHandler

type GetRelationHandler interface {
	HandleGetRelation(ctx context.Context, params Params, q, relatedQuery *query.Scope, relation *mapping.StructField) (*codec.Payload, error)
}

GetRelationHandler is an API interface used for handling 'GetRelation' queries.

type GetRelationMiddlewarer

type GetRelationMiddlewarer interface {
	GetRelatedMiddlewares() []Middleware
}

GetRelationMiddlewarer is an interface that gets middlewares for the 'GetRelated' endpoint.

type InsertHandler

type InsertHandler interface {
	HandleInsert(ctx context.Context, params Params, input *codec.Payload) (*codec.Payload, error)
}

InsertHandler is a handler of an API insert query.

type InsertMiddlewarer

type InsertMiddlewarer interface {
	InsertMiddlewares() []Middleware
}

InsertMiddlewarer is an interface that gets the middlewares for the insert endpoint.

type InsertRelationsMiddlewarer

type InsertRelationsMiddlewarer interface {
	InsertRelationsMiddlewares() []Middleware
}

InsertRelationsMiddlewarer is an interface that gets middlewares for the 'InsertRelation' endpoint.

type ListHandler

type ListHandler interface {
	HandleList(ctx context.Context, params Params, q *query.Scope) (*codec.Payload, error)
}

ListHandler is an interface used for handling the API list request.

type ListMiddlewarer

type ListMiddlewarer interface {
	ListMiddlewares() []Middleware
}

ListMiddlewarer is an interface that gets middlewares for the 'List' endpoint.

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 Options

type Options struct {
	Authorizer    auth.Authorizer
	Authenticator auth.Authenticator
	Controller    *controller.Controller
	DB            database.DB
}

Options are the server initialization options.

type Params

type Params struct {
	Ctx           context.Context
	Authorizer    auth.Authorizer
	Authenticator auth.Authenticator
	DB            database.DB
}

Params are the parameters passed to the server version.

type Server

type Server interface {
	EndpointsGetter
	// Initialize apply controller and initialize given server.
	Initialize(options Options) error
	// 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

type SetRelationsHandler

type SetRelationsHandler interface {
	HandleSetRelations(ctx context.Context, params Params, model mapping.Model, newRelations []mapping.Model, relation *mapping.StructField) (*codec.Payload, error)
}

SetRelationsHandler is an API interface that handles request for setting 'newRelations' for 'model' in field 'relation. This handler is used for all the requests (deleteQuery, update, Insert) relations.

type UpdateHandler

type UpdateHandler interface {
	HandleUpdate(ctx context.Context, params Params, input *codec.Payload) (*codec.Payload, error)
}

UpdateHandler is a handler interface for the API update query.

type UpdateMiddlewarer

type UpdateMiddlewarer interface {
	UpdateMiddlewares() []Middleware
}

UpdateMiddlewarer is an interface that gets middlewares for the update endpoint.

type UpdateRelationsMiddlewarer

type UpdateRelationsMiddlewarer interface {
	UpdateRelationsMiddlewares() []Middleware
}

UpdateRelationsMiddlewarer is an interface that gets middlewares for the 'UpdateRelation' endpoint.

type VersionInitializer

type VersionInitializer interface {
	InitializeVersion(version string, options Options) error
}

VersionInitializer is a server that allows to initializer separate versions.

type VersionedServer

type VersionedServer interface {
	VersionInitializer
	EndpointsGetter
	Serve() error
	Shutdown(ctx context.Context) error
}

VersionedServer is a server that handles multiple versions at once.

Jump to

Keyboard shortcuts

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