resp

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeParseException = "parse_exception"
	ErrTypeAuthException  = "auth_exception"
)
View Source
var (
	ErrReasonRequestBodyIsRequired = "request body is required"
	ErrReasonAuthFailed            = "fail to authenticate"
	ErrReasonAuthCodeNotFound      = "fail to authenticate, auth code not found."
	ErrReasonAuthDecryptFailed     = "fail to decrypt auth code, %s"
	ErrReasonUserNotFound          = "user not found"
	ErrReasonIncorrectHttpMethod2  = "Incorrect HTTP method"
	ErrReasonIncorrectHttpMethod   = "Incorrect HTTP method for uri [%s] and method [%s], allowed: [%s]"
)

Functions

func SendError

func SendError(ctx context.Context, w http.ResponseWriter, httpStatus int, errorMsg string, monitor monitoring.Monitor)

func SendErrorMethodNotAllowed

func SendErrorMethodNotAllowed(ctx context.Context, w http.ResponseWriter, url string, method string, allowMethod string, monitor monitoring.Monitor)

func SendErrorRootCause

func SendErrorRootCause(ctx context.Context, w http.ResponseWriter, httpStatus int, errorType string, errorReason string, monitor monitoring.Monitor)

func SendJson

func SendJson(ctx context.Context, w http.ResponseWriter, obj interface{}, monitor monitoring.Monitor)

func SendJsonBytes

func SendJsonBytes(ctx context.Context, w http.ResponseWriter, bytes []byte, monitor monitoring.Monitor)

func SendJsonHttpReplySuccess

func SendJsonHttpReplySuccess(ctx context.Context, w http.ResponseWriter, obj interface{}, monitor monitoring.Monitor)

Types

type Body

type Body struct {
	Error  interface{} `json:"error"`
	Status int         `json:"status"`
}

func NewBody

func NewBody(error interface{}, status int) *Body

func NewBodyRootCause

func NewBodyRootCause(errorType string, reason string, status int) *Body

type ErrorRootCause

type ErrorRootCause struct {
	RootCauseArr []RootCause `json:"root_cause"`
	RootCause
}

type RootCause

type RootCause struct {
	CType   string `json:"type"`
	CReason string `json:"reason"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL