api

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMethodNotAllowed = &ErrorResponse{HTTPStatusCode: 405, StatusText: "Method not allowed."}

ErrMethodNotAllowed is default 405 router method not allowed

View Source
var ErrNotFound = &ErrorResponse{HTTPStatusCode: 404, StatusText: "Page not found."}

ErrNotFound is default router page not found

Functions

This section is empty.

Types

type Config

type Config struct {
	EnableCORS bool
	Listen     string
}

Config for api configuration variables

type ErrInvalidRequestContent added in v2.5.0

type ErrInvalidRequestContent struct {
	ValidationError error
}

ErrInvalidRequestContent used as custom error for dto logical validations

func (ErrInvalidRequestContent) Error added in v2.5.0

func (err ErrInvalidRequestContent) Error() string

Error is a representation of Error interface method

type ErrorResponse

type ErrorResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrorResponse represents custom error response with statusText and error description

func ErrorForbidden

func ErrorForbidden(errorText string) *ErrorResponse

ErrorForbidden return 403 with given error text

func ErrorInternalServer

func ErrorInternalServer(err error) *ErrorResponse

ErrorInternalServer returns error response with status=500 and given error

func ErrorInvalidRequest

func ErrorInvalidRequest(err error) *ErrorResponse

ErrorInvalidRequest return error response with status = 400 and given error

func ErrorNotFound

func ErrorNotFound(errorText string) *ErrorResponse

ErrorNotFound return 404 with given error text

func ErrorRemoteServerUnavailable

func ErrorRemoteServerUnavailable(err error) *ErrorResponse

ErrorRemoteServerUnavailable return 503 when remote trigger check failed

func ErrorRender

func ErrorRender(err error) *ErrorResponse

ErrorRender return 422 render error and used for response rendering errors

func (*ErrorResponse) Render

Render realization method for render.renderer

Directories

Path Synopsis
nolint nolint nolint nolint nolint nolint nolint nolint nolint
nolint nolint nolint nolint nolint nolint nolint nolint nolint

Jump to

Keyboard shortcuts

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