middleware

package
v0.4.1-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InternalErrorMiddleware

func InternalErrorMiddleware(logger gklog.Logger) endpoint.Middleware

InternalErrorMiddleware is a convenience middleware which can be used in combination with panics. After data is sanitized and validated, services can expect to get reasonable valid data passed (e.g. object not nil, string not empty, ...). With this middleware in place the service can throw an exception with a precond.PreconditionError as payload. This middleware will catch that and translate it into an application level PreconditionError. All other detected panics will be converted into an InternalServerError. In both cases it is most likely that there is an error withing the application or a library. Long story short, this is about failing early in non recoverable situations.

Types

type AppError

type AppError interface {
	Cause() error
}

type BadRequestError

type BadRequestError struct {
	// contains filtered or unexported fields
}

func NewBadRequestError

func NewBadRequestError(msg string) *BadRequestError

func (*BadRequestError) Cause

func (e *BadRequestError) Cause() error

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

type InternalServerError

type InternalServerError struct {
	// contains filtered or unexported fields

} // Unknown internal error, most likely a bug in a service or a library

func NewInternalServerError

func NewInternalServerError(err error) *InternalServerError

func (*InternalServerError) Cause

func (e *InternalServerError) Cause() error

func (*InternalServerError) Error

func (e *InternalServerError) Error() string

type KubernetesError

type KubernetesError struct {
	// contains filtered or unexported fields
}

func NewKubernetesError

func NewKubernetesError(result rest.Result) *KubernetesError

func (*KubernetesError) Body

func (k *KubernetesError) Body() []byte

func (*KubernetesError) Cause

func (k *KubernetesError) Cause() error

func (*KubernetesError) Error

func (k *KubernetesError) Error() string

func (*KubernetesError) Status

func (k *KubernetesError) Status() (*v1.Status, error)

func (*KubernetesError) StatusCode

func (k *KubernetesError) StatusCode() int

type MappingError

type MappingError struct {
	// contains filtered or unexported fields
}

MappingError indicates that mapping a DTO to an entity failed. Can be used by endpoint.Endpoint

func (*MappingError) Cause

func (e *MappingError) Cause() error

func (*MappingError) Error

func (e *MappingError) Error() string

type PreconditionError

type PreconditionError struct {
	// contains filtered or unexported fields

} // Precondition not met, most likely a bug in a service (service)

func (*PreconditionError) Cause

func (e *PreconditionError) Cause() error

func (*PreconditionError) Error

func (e *PreconditionError) Error() string

type ResourceExistsError

type ResourceExistsError struct {
	// contains filtered or unexported fields
}

Resource which should be created exists already. Can be used by endpoint.Endpoint or a Service. E.g. lock

func (*ResourceExistsError) Cause

func (e *ResourceExistsError) Cause() error

func (*ResourceExistsError) Error

func (e *ResourceExistsError) Error() string

type ResourceNotFoundError

type ResourceNotFoundError struct {
	// contains filtered or unexported fields

} // Can be thrown before or by a service call

func NewResourceConflictError

func NewResourceConflictError(msg string) *ResourceNotFoundError

func NewResourceExistsError

func NewResourceExistsError(resource string, name string) *ResourceNotFoundError

func NewResourceNotFoundError

func NewResourceNotFoundError(msg string) *ResourceNotFoundError

func (*ResourceNotFoundError) Cause

func (e *ResourceNotFoundError) Cause() error

func (*ResourceNotFoundError) Error

func (e *ResourceNotFoundError) Error() string

type UnprocessableEntityError

type UnprocessableEntityError struct {
	// contains filtered or unexported fields
}

func NewUnprocessibleEntityError

func NewUnprocessibleEntityError(err error) *UnprocessableEntityError

func (*UnprocessableEntityError) Cause

func (e *UnprocessableEntityError) Cause() error

func (*UnprocessableEntityError) Error

func (e *UnprocessableEntityError) Error() string

type UnsupportedMediaTypeError

type UnsupportedMediaTypeError struct {
	// contains filtered or unexported fields
}

func NewUnsupportedMediaType

func NewUnsupportedMediaType(mediaType string) *UnsupportedMediaTypeError

func (*UnsupportedMediaTypeError) Cause

func (e *UnsupportedMediaTypeError) Cause() error

func (*UnsupportedMediaTypeError) Error

func (e *UnsupportedMediaTypeError) Error() string

type ValidationError

type ValidationError struct {
	// contains filtered or unexported fields
}

ValidationError indicates that a DTO validations failed. Can be used by http.EncodeResponseFunc implementations.

func (*ValidationError) Cause

func (e *ValidationError) Cause() error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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