Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Msgs = map[Code]string{ Success: "Success", Failure: "Failure", ErrRequestDecodeJSON: "Request JSON Decoding failed", ErrAuthInvalidEmail: "Invalid email", ErrAuthInvalidVerificationCode: "Invalid verification code", ErrAuthVerificationCodeExpired: "Verification code expired", ErrAuthInvalidOperation: "Invalid operation", ErrAuthEmptyAlias: "Empty user alias", ErrUnauthorized: "Unauthorized", ErrAuthInvalidToken: "Invalid token", ErrAuthAlreadyDeregistered: "Already deregistered", ErrAuthTokenExpired: "Token expired", ErrAuthEmailAlreadyInUse: "User email already in use", ErrUsernameAlreadyInUse: "Username already in use", ErrUploadEmptyChecksum: "Empty upload file checksum", ErrServiceUnavailable: " Service unavailable", }
Msgs is an HTTP error code to flag map. It's in sync with Codes above.
Functions ¶
func FinalizeResponse ¶
func FinalizeResponse(w http.ResponseWriter, code Code, data interface{})
FinalizeResponse finalizes a response in an handler. It should panic when any error occurs so that the top recovery middleware could cache it.
Types ¶
type Code ¶
type Code int
Code is an custom HTTP code.
const ( Success Code = iota Failure ErrRequestDecodeJSON ErrAuthInvalidEmail ErrAuthInvalidVerificationCode ErrAuthVerificationCodeExpired ErrAuthInvalidOperation ErrAuthEmptyAlias ErrAuthInvalidToken ErrAuthAlreadyDeregistered ErrAuthTokenExpired ErrAuthEmailAlreadyInUse ErrUsernameAlreadyInUse ErrUploadEmptyChecksum )
Common HTTP error code responsing to HTTP requests. It's in sync with Msgs.
type FinalResponse ¶
type FinalResponse struct { Code Code `json:"code"` Msg string `json:"message"` Data interface{} `json:"data,omitempty"` }
FinalResponse is a final uniform response to any request.
Click to show internal directories.
Click to hide internal directories.