Documentation ¶
Overview ¶
filename: 3xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
filename: 4xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
filename: 5xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
filename: codes.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
filename: errors.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
filename: statuses.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
Index ¶
- Variables
- func AddStatus(code Code, httpCode int, message string)
- func MakeBadRequest(message ...interface{}) error
- func MakeCodeError(code Code, err ...error) error
- func MakeConflict(message ...interface{}) error
- func MakeForbidden(message ...interface{}) error
- func MakeHttpError(httpCode int, message ...interface{}) error
- func MakeInsufficientStorage(err error, message ...interface{}) error
- func MakeInternalServerError(err error, message ...interface{}) error
- func MakeLengthRequired(message ...interface{}) error
- func MakeMethodNotAllowed(message ...interface{}) error
- func MakeNotAcceptable(message ...interface{}) error
- func MakeNotFound(message ...interface{}) error
- func MakeNotImplemented(err error, message ...interface{}) error
- func MakeRequestEntityTooLarge(message ...interface{}) error
- func MakeRequestTimeout(message ...interface{}) error
- func MakeRequestedRangeNotSatisfiable(message ...interface{}) error
- func MakeServerError(httpCode int, err error, message ...interface{}) error
- func MakeServiceUnavailable(err error, message ...interface{}) error
- func MakeTeapot(message ...interface{}) error
- func MakeUnauthorized(message ...interface{}) error
- func MakeUnsupportedMediaType(message ...interface{}) error
- func SendFound(c echo.Context, url string) error
- func SendMovedPermanently(c echo.Context, url string) error
- func SendPermanentRedirect(c echo.Context, url string) error
- func SendTemporaryRedirect(c echo.Context, url string) error
- type Code
- type HttpError
- type ServerError
- type Status
Constants ¶
This section is empty.
Variables ¶
var ResponseStatuses = map[Code]Status{ Ok: {http.StatusOK, "SUCCESS/OK"}, BadRequest: {http.StatusBadRequest, "ERRORS/REQUEST/BAD_REQUEST"}, Unauthorized: {http.StatusUnauthorized, "ERRORS/REQUEST/UNAUTHORIZED"}, PaymentRequired: {http.StatusPaymentRequired, "ERRORS/REQUEST/PAYMENT_REQUIRED"}, Forbidden: {http.StatusForbidden, "ERRORS/REQUEST/FORBIDDEN"}, NotFound: {http.StatusNotFound, "ERRORS/REQUEST/NOT_FOUND"}, MethodNotAllowed: {http.StatusMethodNotAllowed, "ERRORS/REQUEST/METHOD_NOT_ALLOWED"}, NotAcceptable: {http.StatusNotAcceptable, "ERRORS/REQUEST/NOT_ACCEPTABLE"}, ProxyAuthRequired: {http.StatusProxyAuthRequired, "ERRORS/REQUEST/PROXY_AUTH_REQUIRED"}, RequestTimeout: {http.StatusRequestTimeout, "ERRORS/REQUEST/REQUEST_TIMEOUT"}, Conflict: {http.StatusConflict, "ERRORS/REQUEST/CONFLICT"}, Gone: {http.StatusGone, "ERRORS/REQUEST/GONE"}, LengthRequired: {http.StatusLengthRequired, "ERRORS/REQUEST/LENGTH_REQUIRED"}, PreconditionFailed: {http.StatusPreconditionFailed, "ERRORS/REQUEST/PRECONDITION_FAILED"}, RequestEntityTooLarge: {http.StatusRequestEntityTooLarge, "ERRORS/REQUEST/REQUEST_ENTITY_TOO_LARGE"}, RequestURITooLong: {http.StatusRequestURITooLong, "ERRORS/REQUEST/REQUEST_URI_TOO_LONG"}, UnsupportedMediaType: {http.StatusUnsupportedMediaType, "ERRORS/REQUEST/UNSUPPORTED_MEDIA_TYPE"}, RequestedRangeNotSatisfiable: {http.StatusRequestedRangeNotSatisfiable, "ERRORS/REQUEST/REQUESTED_RANGE_NOT_SATISFIABLE"}, ExpectationFailed: {http.StatusExpectationFailed, "ERRORS/REQUEST/EXPECTATION_FAILED"}, Teapot: {http.StatusTeapot, "ERRORS/REQUEST/TEAPOT"}, MisdirectedRequest: {http.StatusMisdirectedRequest, "ERRORS/REQUEST/MISDIRECTED_REQUEST"}, UnprocessableEntity: {http.StatusUnprocessableEntity, "ERRORS/REQUEST/UNPROCESSABLE_ENTITY"}, Locked: {http.StatusLocked, "ERRORS/REQUEST/LOCKED"}, FailedDependency: {http.StatusFailedDependency, "ERRORS/REQUEST/FAILED_DEPENDENCY"}, TooEarly: {http.StatusTooEarly, "ERRORS/REQUEST/TOO_EARLY"}, UpgradeRequired: {http.StatusUpgradeRequired, "ERRORS/REQUEST/UPGRADE_REQUIRED"}, PreconditionRequired: {http.StatusPreconditionRequired, "ERRORS/REQUEST/PRECONDITION_REQUIRED"}, TooManyRequests: {http.StatusTooManyRequests, "ERRORS/REQUEST/TOO_MANY_REQUEST"}, RequestHeaderFieldsTooLarge: {http.StatusRequestHeaderFieldsTooLarge, "ERRORS/REQUEST/REQUEST_HEADER_FIELDS_TOO_LARGE"}, UnavailableForLegalReasons: {http.StatusUnavailableForLegalReasons, "ERRORS/REQUEST/UNAVAILABLE_FOR_LEGAL_REASONS"}, InternalServerError: {http.StatusInternalServerError, "ERRORS/REQUEST/INTERNAL_SERVER_ERROR"}, NotImplemented: {http.StatusNotImplemented, "ERRORS/REQUEST/NOT_IMPLEMENTED"}, BadGateway: {http.StatusBadGateway, "ERRORS/REQUEST/BAD_GATEWAY"}, ServiceUnavailable: {http.StatusServiceUnavailable, "ERRORS/REQUEST/SERVICE_UNAVAILABLE"}, GatewayTimeout: {http.StatusGatewayTimeout, "ERRORS/REQUEST/GATEWAY_TIMEOUT"}, HTTPVersionNotSupported: {http.StatusHTTPVersionNotSupported, "ERRORS/REQUEST/HTTP_VERSION_NOT_SUPPORTED"}, VariantAlsoNegotiates: {http.StatusVariantAlsoNegotiates, "ERRORS/REQUEST/VARIANT_ALSO_NEGOTIATES"}, InsufficientStorage: {http.StatusInsufficientStorage, "ERRORS/REQUEST/INSUFFICIENT_STORAGE"}, LoopDetected: {http.StatusLoopDetected, "ERRORS/REQUEST/LOOP_DETECTED"}, NotExtended: {http.StatusNotExtended, "ERRORS/REQUEST/NOT_EXTENDED"}, NetworkAuthenticationRequired: {http.StatusNetworkAuthenticationRequired, "ERRORS/REQUEST/NETWORK_AUTHENTICATION_REQUIRED"}, }
Functions ¶
func MakeBadRequest ¶
func MakeBadRequest(message ...interface{}) error
Description :
This function is a short hand for sending a http 400 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeCodeError ¶
func MakeConflict ¶
func MakeConflict(message ...interface{}) error
Description :
This function is a short hand for sending a http 408 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeForbidden ¶
func MakeForbidden(message ...interface{}) error
Description :
This function is a short hand for sending a http 403 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeHttpError ¶
func MakeInsufficientStorage ¶
Description :
This function is a short hand for sending a http 507 error
Parameters :
err error : Required The error that causes the request fail. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeInternalServerError ¶
Description :
This function is a short hand for sending a http 500 error
Parameters :
err error : Required The error that causes the request fail. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeLengthRequired ¶
func MakeLengthRequired(message ...interface{}) error
Description :
This function is a short hand for sending a http 411 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeMethodNotAllowed ¶
func MakeMethodNotAllowed(message ...interface{}) error
Description :
This function is a short hand for sending a http 405 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeNotAcceptable ¶
func MakeNotAcceptable(message ...interface{}) error
Description :
This function is a short hand for sending a http 406 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeNotFound ¶
func MakeNotFound(message ...interface{}) error
Description :
This function is a short hand for sending a http 404 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeNotImplemented ¶
Description :
This function is a short hand for sending a http 501 error
Parameters :
err error : Required The error that causes the request fail. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeRequestEntityTooLarge ¶
func MakeRequestEntityTooLarge(message ...interface{}) error
Description :
This function is a short hand for sending a http 413 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeRequestTimeout ¶
func MakeRequestTimeout(message ...interface{}) error
Description :
This function is a short hand for sending a http 408 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeRequestedRangeNotSatisfiable ¶
func MakeRequestedRangeNotSatisfiable(message ...interface{}) error
Description :
This function is a short hand for sending a http 416 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeServerError ¶
func MakeServiceUnavailable ¶
Description :
This function is a short hand for sending a http 503 error
Parameters :
err error : Required The error that causes the request fail. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeTeapot ¶
func MakeTeapot(message ...interface{}) error
Description :
This function is a short hand for sending a http 418 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeUnauthorized ¶
func MakeUnauthorized(message ...interface{}) error
Description :
This function is a short hand for sending a http 401 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func MakeUnsupportedMediaType ¶
func MakeUnsupportedMediaType(message ...interface{}) error
Description :
This function is a short hand for sending a http 415 error
Parameters :
c echo.Context : Required The current request context from echo. Must never be set to nil. message ...interface{} : Optional Informations about the response. Used to fill the message field of the response template.
Returns :
error : The encountered error if there has one. Nil otherwise
func SendFound ¶
Description :
This function is a short hand for sending a http 302 response
Parameters :
c echo.Context : The current request context from echo. Must never be set to nil. url string : The url to redirect
Returns :
error : The encountered error if there has one. Nil otherwise
func SendMovedPermanently ¶
Description :
This function is a short hand for sending a http 301 response
Parameters :
c echo.Context : The current request context from echo. Must never be set to nil. url string : The url to redirect
Returns :
error : The encountered error if there has one. Nil otherwise
func SendPermanentRedirect ¶
Description :
This function is a short hand for sending a http 308 response
Parameters :
c echo.Context : The current request context from echo. Must never be set to nil. url string : The url to redirect
Returns :
error : The encountered error if there has one. Nil otherwise
func SendTemporaryRedirect ¶
Description :
This function is a short hand for sending a http 307 response
Parameters :
c echo.Context : The current request context from echo. Must never be set to nil. url string : The url to redirect
Returns :
error : The encountered error if there has one. Nil otherwise
Types ¶
type Code ¶
type Code int
const ( Ok Code = iota // Theses codes are defaults errcode for http codes. // This allow IRSA to handle echo errors and provide nice codes // // Some (iota + weird numbers) are required because every 400 codes does not follows // (So we step over them) BadRequest Code = iota + 399 // RFC 7231, 6.5.1 PaymentRequired // RFC 7231, 6.5.2 Forbidden // RFC 7231, 6.5.3 NotFound // RFC 7231, 6.5.4 MethodNotAllowed // RFC 7231, 6.5.5 NotAcceptable // RFC 7231, 6.5.6 ProxyAuthRequired // RFC 7235, 3.2 RequestTimeout // RFC 7231, 6.5.7 Conflict // RFC 7231, 6.5.8 Gone // RFC 7231, 6.5.9 LengthRequired // RFC 7231, 6.5.10 PreconditionFailed // RFC 7232, 4.2 RequestEntityTooLarge // RFC 7231, 6.5.11 RequestURITooLong // RFC 7231, 6.5.12 UnsupportedMediaType // RFC 7231, 6.5.13 RequestedRangeNotSatisfiable // RFC 7233, 4.4 ExpectationFailed // RFC 7231, 6.5.14 Teapot // RFC 7168, 2.3.3 MisdirectedRequest Code = iota + 401 // RFC 7540, 9.1.2 UnprocessableEntity // RFC 4918, 11.2 Locked // RFC 4918, 11.3 FailedDependency // RFC 4918, 11.4 TooEarly // RFC 8470, 5.2. UpgradeRequired // RFC 7231, 6.5.15 PreconditionRequired Code = iota + 402 // RFC 6585, 3 TooManyRequests // RFC 6585, 4 RequestHeaderFieldsTooLarge Code = iota + 403 // RFC 6585, 5 InternalServerError Code = iota + 470 // RFC 7231, 6.6.1 NotImplemented // RFC 7231, 6.6.2 BadGateway // RFC 7231, 6.6.3 GatewayTimeout // RFC 7231, 6.6.5 HTTPVersionNotSupported // RFC 7231, 6.6.6 VariantAlsoNegotiates // RFC 2295, 8.1 InsufficientStorage // RFC 4918, 11.5 LoopDetected // RFC 5842, 7.2 NotExtended Code = iota + 471 // RFC 2774, 7 NetworkAuthenticationRequired // RFC 6585, 6 StatusPadding = 1000 )
type HttpError ¶
type ServerError ¶
func (ServerError) Error ¶
func (n ServerError) Error() string
Directories ¶
Path | Synopsis |
---|---|
filename: 2xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: error.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: respond.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
|
filename: 2xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: error.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: respond.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published |
filename: 2xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: error.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: respond.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published
|
filename: 2xx.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: error.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published filename: respond.go author: Thomas Lombard copyright: Thomas Lombard license: MIT status: published |