Documentation ¶
Index ¶
Constants ¶
const ( // BadRequestMessage is the default message when the input parameters on a request are wrong or it is malformed. BadRequestMessage = "Invalid request parameters." // ResourceNotFoundMessage is the default message when a requested resource is not available. ResourceNotFoundMessage = "Resource not found." // MethodNotAllowedMessage is the default message when a HTTP verb is forbidden on a resource. MethodNotAllowedMessage = "Method not allowed on the current resource." // InternalServerErrorMessage is the default message when an unexpected condition occurs. InternalServerErrorMessage = "Internal Server Error." UnauthorizedMessage = "Unauthorized" )
Variables ¶
This section is empty.
Functions ¶
func CreateRouter ¶
func ErrorWrapper ¶
func ErrorWrapper(handlerFunc WrapperFunc, c *gin.Context)
ErrorWrapper if handlerFunc return a error,then response will be composed from error's information.
func MethodNotAllowedHandler ¶
MethodNotAllowedHandler handles requests for registered routes with invalid http methods on their requests
func NoRouteHandler ¶
NoRouteHandler handles requests for non registered routes
Types ¶
type APIError ¶
type APIError struct { Status int `json:"status"` Message string `json:"message"` Err string `json:"error"` }
APIError represents the standard error structure for the HTTP responses.
func NewBadRequest ¶
NewBadRequest creates an API Error for an invalid or malformed request.
func NewInternalServerError ¶
NewInternalServerError creates an API Error for an unexpected condition.
func NewMethodNotAllowed ¶
NewMethodNotAllowed creates an API Error for a forbidden verb on a resource.
func NewResourceNotFound ¶
NewResourceNotFound creates an API Error for an unexisting resource.
func NewUnauthorized ¶
type WrapperFunc ¶
WrapperFunc is the func type for the custom handlers.