Documentation ¶
Index ¶
- func ErrorJSON(c *gin.Context, status int, messageTypes *MessageTypes, err error)
- func JSON(c *gin.Context, status int, messageTypes *MessageTypes, messages *Messages, ...)
- func KnownErrorJSON(c *gin.Context, status int, messageType string, err error)
- func RedirectionJSON(c *gin.Context, status int, messageType string, msg string)
- func SuccessJSON(c *gin.Context, status int, messageType string, msg string)
- func UnknownErrorJSON(c *gin.Context, status int, err error)
- type BasicResponse
- type MessageTypes
- type Messages
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorJSON ¶
func ErrorJSON(c *gin.Context, status int, messageTypes *MessageTypes, err error)
ErrorJSON is a json response of errors.
func KnownErrorJSON ¶
KnownErrorJSON is json response of known error.
func RedirectionJSON ¶
RedirectionJSON is a json response of 3xx.
func SuccessJSON ¶
SuccessJSON is a json response of 2xx.
Types ¶
type BasicResponse ¶
type BasicResponse struct { Status int `json:"status",description:"http status"` MessageType string `json:"messageType", description:"response message type for frontend I18N."` Message string `json:"message",description:"response message"` }
BasicResponse is a basic response.
func KnownError ¶
func KnownError(status int, messageType string, err error) *BasicResponse
KnownError is a basic response of know errors.
func Redirection ¶
func Redirection(status int, messageType string, msg string) *BasicResponse
Redirection is a basic response of 3xx.
func Success ¶
func Success(status int, messageType string, msg string) *BasicResponse
Success is a basic response of 2xx.
func UnknownError ¶
func UnknownError(status int, err error) *BasicResponse
UnknownError is a basic response of unknown errors.
type MessageTypes ¶
type MessageTypes struct { OK string `description:"200"` Created string `description:"201"` NotModified string `description:"304"` BadRequest string `description:"400"` PaymentRequired string `description:"402"` Forbidden string `description:"403"` NotFound string `description:"404"` MethodNotAllowed string `description:"405"` InternalServerError string `description:"500"` }
MessageTypes is an array of message types that using in frontend. OK : 200 Created : 201 NotModified : 304 BadRequest : 400 Unauthorized : 401 PaymentRequired : 402 Forbidden : 403 NotFound : 404 MethodNotAllowed : 405 InternalServerError : 500