Documentation
¶
Index ¶
- Constants
- Variables
- func GetErrorCode(err error) string
- func GetHTTPCode(code string) int
- func GetHTTPStatus(code int) string
- func Type(err error) error
- type ErrChain
- type InvalidError
- type JSONResponse
- func (r *JSONResponse) APIStatusAccepted() *JSONResponse
- func (r *JSONResponse) APIStatusBadRequest() *JSONResponse
- func (r *JSONResponse) APIStatusCreated() *JSONResponse
- func (r *JSONResponse) APIStatusErrorUnknown() *JSONResponse
- func (r *JSONResponse) APIStatusForbidden() *JSONResponse
- func (r *JSONResponse) APIStatusInvalidAuthentication() *JSONResponse
- func (r *JSONResponse) APIStatusNoContent() *JSONResponse
- func (r *JSONResponse) APIStatusNotFound() *JSONResponse
- func (r *JSONResponse) APIStatusSuccess() *JSONResponse
- func (r *JSONResponse) APIStatusUnauthorized() *JSONResponse
- func (r *JSONResponse) GetBody() []byte
- func (r *JSONResponse) Send(w http.ResponseWriter)
- func (r *JSONResponse) SetCode(code string) *JSONResponse
- func (r *JSONResponse) SetData(data interface{}) *JSONResponse
- func (r *JSONResponse) SetError(err error, a ...string) *JSONResponse
- func (r *JSONResponse) SetHTML() *JSONResponse
- func (r *JSONResponse) SetLatency(latency float64) *JSONResponse
- func (r *JSONResponse) SetMessage(msg string) *JSONResponse
- func (r *JSONResponse) SetResult(result interface{}) *JSONResponse
- func (r *JSONResponse) SetStatus(status string) *JSONResponse
- func (r *JSONResponse) SetStatusCode(statusCode int) *JSONResponse
Constants ¶
View Source
const ( StatusCodeGenericSuccess = "200000" StatusCodeAccepted = "202000" StatusCodeBadRequest = "400000" StatusCodeAlreadyRegistered = "400001" StatusCodeForbidden = "403000" StatusCodeNotFound = "404000" StatusCodeConflict = "409000" StatusCodeGenericPreconditionFailed = "412000" StatusCodeOTPLimitReached = "412550" StatusCodeNoLinkerExist = "412553" StatusCodeInternalError = "500000" StatusCodeFailedSellBatch = "500100" StatusCodeFailedOTP = "503000" StatusCodeTimeoutError = "504000" StatusCodeMethodNotAllowed = "405000" )
Variables ¶
View Source
var ( ErrBadRequest = errors.New("Bad request") ErrForbiddenResource = errors.New("Forbidden resource") ErrNotFound = errors.New("Not Found") ErrPreConditionFailed = errors.New("Precondition failed") ErrInternalServerError = errors.New("Internal server error") ErrTimeoutError = errors.New("Timeout error") ErrConflict = errors.New("Conflict") ErrMethodNotAllowed = errors.New("Method not allowed") ErrInvalidGrantType = errors.New("Invalid grant type") ErrInvalidClientIDOrSecret = errors.New("Invalid client ID or secret") ErrAuthorizationCodeNotFound = errors.New("Authorization code not found") ErrAuthorizationCodeExpired = errors.New("Authorization code expired") ErrInvalidRedirectURI = errors.New("Invalid redirect URI") ErrInvalidScope = errors.New("Invalid scope") ErrInvalidUsernameOrPassword = errors.New("Invalid username or password") ErrRefreshTokenNotFound = errors.New("Refresh token not found") ErrRefreshTokenExpired = errors.New("Refresh token expired") ErrRequestedScopeCannotBeGreater = errors.New("Requested scope cannot be greater") ErrTokenMissing = errors.New("Token missing") ErrTokenHintInvalid = errors.New("Invalid token hint") ErrAccessTokenNotFound = errors.New("Access token not found") ErrAccessTokenExpired = errors.New("Access token expired") ErrClientNotFound = errors.New("Client not found") ErrInvalidClientSecret = errors.New("Invalid client secret") ErrClientIDTaken = errors.New("Client ID taken") ErrRoleNotFound = errors.New("Role not found") MinPasswordLength = 6 ErrPasswordTooShort = fmt.Errorf( "Password must be at least %d characters long", MinPasswordLength, ) ErrUserNotFound = errors.New("User not found") ErrInvalidUserPassword = errors.New("Invalid user password") ErrCannotSetEmptyUsername = errors.New("Cannot set empty username") ErrUserPasswordNotSet = errors.New("User password not set") ErrUsernameTaken = errors.New("Username taken") ErrInvalidAuthorizationCodeGrantRequest = errors.New("Invalid authorization code request") ErrInvalidPasswordGrantRequest = errors.New("Invalid password grant request") ErrInvalidClientCredentialsGrantRequest = errors.New("Invalid client credentials grant request") ErrInvalidIntrospectRequest = errors.New("Invalid introspect request") ErrSessonNotStarted = errors.New("Session not started") )
Functions ¶
func GetErrorCode ¶
func GetHTTPCode ¶
func GetHTTPStatus ¶
Types ¶
type InvalidError ¶
type InvalidError struct {
// contains filtered or unexported fields
}
func NewInvalidError ¶
func NewInvalidError(msg string) *InvalidError
func NewInvalidErrorf ¶
func NewInvalidErrorf(msg string, args ...interface{}) *InvalidError
func (*InvalidError) Error ¶
func (ie *InvalidError) Error() string
type JSONResponse ¶
type JSONResponse struct { Data interface{} `json:"data,omitempty"` Message string `json:"message,omitempty"` Code string `json:"code"` StatusCode int `json:"status_code"` Status string `json:"status"` ErrorString string `json:"error,omitempty"` Error error `json:"-"` RealError string `json:"-"` Latency string `json:"latency,omitempty"` Log map[string]interface{} `json:"-"` HTMLPage bool `json:"-"` Result interface{} `json:"result,omitempty"` }
func NewJSONResponse ¶
func NewJSONResponse() *JSONResponse
func (*JSONResponse) APIStatusAccepted ¶
func (r *JSONResponse) APIStatusAccepted() *JSONResponse
APIStatusAccepted
func (*JSONResponse) APIStatusBadRequest ¶
func (r *JSONResponse) APIStatusBadRequest() *JSONResponse
APIStatusBadRequest
func (*JSONResponse) APIStatusCreated ¶
func (r *JSONResponse) APIStatusCreated() *JSONResponse
APIStatusCreated
func (*JSONResponse) APIStatusErrorUnknown ¶
func (r *JSONResponse) APIStatusErrorUnknown() *JSONResponse
APIStatusErrorUnknown
func (*JSONResponse) APIStatusForbidden ¶
func (r *JSONResponse) APIStatusForbidden() *JSONResponse
APIStatusForbidden
func (*JSONResponse) APIStatusInvalidAuthentication ¶
func (r *JSONResponse) APIStatusInvalidAuthentication() *JSONResponse
APIStatusInvalidAuthentication
func (*JSONResponse) APIStatusNoContent ¶
func (r *JSONResponse) APIStatusNoContent() *JSONResponse
APIStatusNoContent
func (*JSONResponse) APIStatusNotFound ¶
func (r *JSONResponse) APIStatusNotFound() *JSONResponse
APIStatusNotFound
func (*JSONResponse) APIStatusSuccess ¶
func (r *JSONResponse) APIStatusSuccess() *JSONResponse
APIStatusSuccess for standard request api status success
func (*JSONResponse) APIStatusUnauthorized ¶
func (r *JSONResponse) APIStatusUnauthorized() *JSONResponse
APIStatusUnauthorized
func (*JSONResponse) GetBody ¶
func (r *JSONResponse) GetBody() []byte
func (*JSONResponse) Send ¶
func (r *JSONResponse) Send(w http.ResponseWriter)
func (*JSONResponse) SetCode ¶
func (r *JSONResponse) SetCode(code string) *JSONResponse
func (*JSONResponse) SetData ¶
func (r *JSONResponse) SetData(data interface{}) *JSONResponse
func (*JSONResponse) SetError ¶
func (r *JSONResponse) SetError(err error, a ...string) *JSONResponse
func (*JSONResponse) SetHTML ¶
func (r *JSONResponse) SetHTML() *JSONResponse
func (*JSONResponse) SetLatency ¶
func (r *JSONResponse) SetLatency(latency float64) *JSONResponse
func (*JSONResponse) SetMessage ¶
func (r *JSONResponse) SetMessage(msg string) *JSONResponse
func (*JSONResponse) SetResult ¶
func (r *JSONResponse) SetResult(result interface{}) *JSONResponse
func (*JSONResponse) SetStatus ¶
func (r *JSONResponse) SetStatus(status string) *JSONResponse
func (*JSONResponse) SetStatusCode ¶
func (r *JSONResponse) SetStatusCode(statusCode int) *JSONResponse
Click to show internal directories.
Click to hide internal directories.