httpx

package
v0.0.0-...-fa6ae4b Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

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
	ErrUnauthorized
	ErrAuthInvalidToken
	ErrAuthAlreadyDeregistered
	ErrAuthTokenExpired
	ErrAuthEmailAlreadyInUse

	ErrUsernameAlreadyInUse

	ErrUploadEmptyChecksum

	ErrServiceUnavailable
)

Common HTTP error code responsing to HTTP requests. It's in sync with Msgs.

func (Code) Msg

func (c Code) Msg() string

Msg returns the interpretation of code.

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.

Jump to

Keyboard shortcuts

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