Documentation
¶
Index ¶
- func BadGatewayResponse(writer http.ResponseWriter, message string)
- func BadRequestResponse(writer http.ResponseWriter, message string)
- func ConflictResponse(writer http.ResponseWriter, message string)
- func ErrorResponse(w http.ResponseWriter, e IError)
- func ExpectationFailedResponse(writer http.ResponseWriter, message string)
- func FailedDependencyResponse(writer http.ResponseWriter, message string)
- func ForbiddenResponse(writer http.ResponseWriter, message string)
- func GatewayTimeoutResponse(writer http.ResponseWriter, message string)
- func GoneResponse(writer http.ResponseWriter, message string)
- func HTTPVersionNotSupportedResponse(writer http.ResponseWriter, message string)
- func InsufficientStorageResponse(writer http.ResponseWriter, message string)
- func InternalServerErrorResponse(writer http.ResponseWriter, message string)
- func LengthRequiredResponse(writer http.ResponseWriter, message string)
- func LockedResponse(writer http.ResponseWriter, message string)
- func LoopDetectedResponse(writer http.ResponseWriter, message string)
- func MethodNotAllowedResponse(writer http.ResponseWriter, message string)
- func MisdirectedRequestResponse(writer http.ResponseWriter, message string)
- func NetworkAuthenticationRequiredResponse(writer http.ResponseWriter, message string)
- func NotAcceptableResponse(writer http.ResponseWriter, message string)
- func NotExtendedResponse(writer http.ResponseWriter, message string)
- func NotFoundResponse(writer http.ResponseWriter, message string)
- func NotImplementedResponse(writer http.ResponseWriter, message string)
- func OkResponse(writer http.ResponseWriter, message string, data interface{}, meta interface{})
- func PaymentRequiredResponse(writer http.ResponseWriter, message string)
- func PreconditionFailedResponse(writer http.ResponseWriter, message string)
- func PreconditionRequiredResponse(writer http.ResponseWriter, message string)
- func ProxyAuthRequiredResponse(writer http.ResponseWriter, message string)
- func RequestEntityTooLargeResponse(writer http.ResponseWriter, message string)
- func RequestHeaderFieldsTooLargeResponse(writer http.ResponseWriter, message string)
- func RequestTimeoutResponse(writer http.ResponseWriter, message string)
- func RequestURITooLongResponse(writer http.ResponseWriter, message string)
- func RequestedRangeNotSatisfiableResponse(writer http.ResponseWriter, message string)
- func SendJson(writer http.ResponseWriter, httpCode int, data interface{})
- func ServiceUnavailableResponse(writer http.ResponseWriter, message string)
- func TeapotResponse(writer http.ResponseWriter, message string)
- func TooEarlyResponse(writer http.ResponseWriter, message string)
- func TooManyRequestsResponse(writer http.ResponseWriter, message string)
- func UnauthorizedResponse(writer http.ResponseWriter, message string)
- func UnavailableForLegalReasonsResponse(writer http.ResponseWriter, message string)
- func UnprocessableEntityResponse(writer http.ResponseWriter, message string)
- func UnsupportedMediaTypeResponse(writer http.ResponseWriter, message string)
- func UpgradeRequiredResponse(writer http.ResponseWriter, message string)
- func VariantAlsoNegotiatesResponse(writer http.ResponseWriter, message string)
- type Error
- func (e *Error) AppendDetail(message string, key *string, code *int) IError
- func (e *Error) Error() string
- func (e *Error) GetCode() *int
- func (e *Error) GetDetails() *ErrorDetails
- func (e *Error) GetHttpCode() int
- func (e *Error) SetCode(code *int) IError
- func (e *Error) SetDetails(details *ErrorDetails) IError
- type ErrorDetails
- type ErrorField
- type IError
- type JsonDetailError
- type JsonError
- type JsonResponse
- type Meta
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadGatewayResponse ¶
func BadGatewayResponse(writer http.ResponseWriter, message string)
Bad Gateway 502
func BadRequestResponse ¶
func BadRequestResponse(writer http.ResponseWriter, message string)
Bad Request 400
func ConflictResponse ¶
func ConflictResponse(writer http.ResponseWriter, message string)
Conflict 409
func ExpectationFailedResponse ¶
func ExpectationFailedResponse(writer http.ResponseWriter, message string)
Expectation Failed 417
func FailedDependencyResponse ¶
func FailedDependencyResponse(writer http.ResponseWriter, message string)
Failed Dependency 424
func ForbiddenResponse ¶
func ForbiddenResponse(writer http.ResponseWriter, message string)
Forbidden 403
func GatewayTimeoutResponse ¶
func GatewayTimeoutResponse(writer http.ResponseWriter, message string)
Gateway Timeout 504
func HTTPVersionNotSupportedResponse ¶
func HTTPVersionNotSupportedResponse(writer http.ResponseWriter, message string)
HTTP Version Not Supported 505
func InsufficientStorageResponse ¶
func InsufficientStorageResponse(writer http.ResponseWriter, message string)
Insufficient Storage 507
func InternalServerErrorResponse ¶
func InternalServerErrorResponse(writer http.ResponseWriter, message string)
Internal Server Error 500
func LengthRequiredResponse ¶
func LengthRequiredResponse(writer http.ResponseWriter, message string)
Length Required 411
func LoopDetectedResponse ¶
func LoopDetectedResponse(writer http.ResponseWriter, message string)
Loop Detected 508
func MethodNotAllowedResponse ¶
func MethodNotAllowedResponse(writer http.ResponseWriter, message string)
Method Not Allowed 405
func MisdirectedRequestResponse ¶
func MisdirectedRequestResponse(writer http.ResponseWriter, message string)
Misdirected Request 421
func NetworkAuthenticationRequiredResponse ¶
func NetworkAuthenticationRequiredResponse(writer http.ResponseWriter, message string)
Network Authentication Required 511
func NotAcceptableResponse ¶
func NotAcceptableResponse(writer http.ResponseWriter, message string)
Not Acceptable 406
func NotExtendedResponse ¶
func NotExtendedResponse(writer http.ResponseWriter, message string)
Not Extended 510
func NotFoundResponse ¶
func NotFoundResponse(writer http.ResponseWriter, message string)
Not Found 404
func NotImplementedResponse ¶
func NotImplementedResponse(writer http.ResponseWriter, message string)
Not Implemented 501
func OkResponse ¶
func OkResponse(writer http.ResponseWriter, message string, data interface{}, meta interface{})
Ok 200
func PaymentRequiredResponse ¶
func PaymentRequiredResponse(writer http.ResponseWriter, message string)
Payment Required 402
func PreconditionFailedResponse ¶
func PreconditionFailedResponse(writer http.ResponseWriter, message string)
Precondition Failed 412
func PreconditionRequiredResponse ¶
func PreconditionRequiredResponse(writer http.ResponseWriter, message string)
Precondition Required 428
func ProxyAuthRequiredResponse ¶
func ProxyAuthRequiredResponse(writer http.ResponseWriter, message string)
Proxy Auth Required 407
func RequestEntityTooLargeResponse ¶
func RequestEntityTooLargeResponse(writer http.ResponseWriter, message string)
Request Entity Too Large 413
func RequestHeaderFieldsTooLargeResponse ¶
func RequestHeaderFieldsTooLargeResponse(writer http.ResponseWriter, message string)
Request Header Fields Too Large 431
func RequestTimeoutResponse ¶
func RequestTimeoutResponse(writer http.ResponseWriter, message string)
Request Timeout 408
func RequestURITooLongResponse ¶
func RequestURITooLongResponse(writer http.ResponseWriter, message string)
Request URI Too Long 414
func RequestedRangeNotSatisfiableResponse ¶
func RequestedRangeNotSatisfiableResponse(writer http.ResponseWriter, message string)
Requested Range Not Satisfiable 416
func SendJson ¶
func SendJson(writer http.ResponseWriter, httpCode int, data interface{})
Sent json into http writer
func ServiceUnavailableResponse ¶
func ServiceUnavailableResponse(writer http.ResponseWriter, message string)
Service Unavailable 503
func TooEarlyResponse ¶
func TooEarlyResponse(writer http.ResponseWriter, message string)
Too Early 425
func TooManyRequestsResponse ¶
func TooManyRequestsResponse(writer http.ResponseWriter, message string)
Too Many Requests 429
func UnauthorizedResponse ¶
func UnauthorizedResponse(writer http.ResponseWriter, message string)
Unauthorized 401
func UnavailableForLegalReasonsResponse ¶
func UnavailableForLegalReasonsResponse(writer http.ResponseWriter, message string)
Unavailable For Legal Reasons 451
func UnprocessableEntityResponse ¶
func UnprocessableEntityResponse(writer http.ResponseWriter, message string)
Unprocessable Entity 421
func UnsupportedMediaTypeResponse ¶
func UnsupportedMediaTypeResponse(writer http.ResponseWriter, message string)
Unsupported Media Type 415
func UpgradeRequiredResponse ¶
func UpgradeRequiredResponse(writer http.ResponseWriter, message string)
Upgrade Required 426
func VariantAlsoNegotiatesResponse ¶
func VariantAlsoNegotiatesResponse(writer http.ResponseWriter, message string)
Variant Also Negotiates 506
Types ¶
type Error ¶
type Error struct {
// Error code
Code *int `json:"code,omitempty"`
// Error details
Errors *ErrorDetails `json:"errors,omitempty"`
// Message
Message string `json:"message"`
// contains filtered or unexported fields
}
Rest error struct
func (*Error) AppendDetail ¶
Append detail
type ErrorField ¶
type ErrorField struct {
// Field error code
Code *int `json:"code,omitempty"`
// Field name
Key *string `json:"key,omitempty"`
// Message
Message string `json:"message"`
}
Rest error detail
type IError ¶
type IError interface {
// Append error detail
AppendDetail(message string, key *string, code *int) IError
// Get rest error details
GetDetails() *ErrorDetails
// Get message
Error() string
// Get http code
GetHttpCode() int
// Set detail
SetDetails(details *ErrorDetails) IError
// Set error code
SetCode(code *int) IError
// Get code
GetCode() *int
}
Rest error interface
func ReadJsonBody ¶
Прочитать тело дескриптор запроса
type JsonDetailError ¶
type JsonError ¶
type JsonError struct {
// Message of error
Message string `json:"message"`
// Code of error
Code string `json:"code"`
// Errors detail
Data []JsonDetailError `json:"data,omitempty"`
}
type JsonResponse ¶
type JsonResponse struct {
// Debug information
Debug interface{} `json:"debug,omitempty"`
// Body
Data interface{} `json:"data,omitempty"`
// Meta information
Meta interface{} `json:"meta,omitempty"`
// Error information
Error *JsonError `json:"error,omitempty"`
}
func NewErrorJsonResponse ¶
func NewErrorJsonResponse(debug interface{}, message, code string) *JsonResponse
New Json Response with error
func NewOkJsonResponse ¶
func NewOkJsonResponse(debug interface{}, data interface{}, meta interface{}) *JsonResponse
New Json Response without error
type Response ¶
type Response struct {
// Client data
Data interface{} `json:"data,omitempty"`
// Code
Code *int `json:"code,omitempty"`
// Error details
Errors interface{} `json:"errors,omitempty"`
// Client message for end user
Message string `json:"message,omitempty"`
// Meta data
Meta interface{} `json:"meta,omitempty"`
// contains filtered or unexported fields
}
Rest response object
func NewResponse ¶
func NewResponse(writer http.ResponseWriter, code int) *Response
Create new rest response