httperrors

package
v0.0.0-...-688b8c7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTPCodeInvalidAuth is used when the authentication is invalid.
	HTTPCodeInvalidAuth = HTTPCode("invalid_auth")

	// HTTPCodeInternalServerError is used when there is an internal server error.
	HTTPCodeInternalServerError = HTTPCode("internal_server_error")

	// HTTPCodeSameNode is an error that is used when the user is on the same node for a cross-node specific request.
	HTTPCodeSameNode = HTTPCode("same_node")

	// HTTPCodeHalfAuthenticated is used when the user is half authenticated.
	HTTPCodeHalfAuthenticated = HTTPCode("half_authenticated")

	// HTTPCodeNoPasswordAuthSupport is used when the user does not support password authentication.
	HTTPCodeNoPasswordAuthSupport = HTTPCode("no_password_auth_support")

	// HTTPCodeInvalidBody is used when the body is invalid.
	HTTPCodeInvalidBody = HTTPCode("invalid_body")
)

Variables

This section is empty.

Functions

func Throw

func Throw(w http.ResponseWriter, r *http.Request, err HTTPError)

Throw is used to throw an HTTP error in the best way possible.

Types

type HTTPCode

type HTTPCode string

HTTPCode is used to define the HTTP error code.

type HTTPError

type HTTPError interface {
	// contains filtered or unexported methods
}

HTTPError is used to define a interface that represents an HTTP error.

type HalfAuthentication

type HalfAuthentication struct {
	// SupportedMethods is the supported authentication methods.
	SupportedMethods []string `json:"supported_methods" xml:"supported_methods" msgpack:"supported_methods"`

	// HalfToken is the half token that can be used to complete the authentication.
	HalfToken string `json:"half_token" xml:"half_token" msgpack:"half_token"`
}

HalfAuthentication is thrown when the user is only partially authenticated. This is used for 2FA.

func (HalfAuthentication) Error

func (h HalfAuthentication) Error() string

Error implements the error interface.

type InternalServerError

type InternalServerError struct{}

InternalServerError is used to define an internal server error.

func (InternalServerError) EncodeMsgpack

func (i InternalServerError) EncodeMsgpack(e *msgpack.Encoder) error

EncodeMsgpack is used to marshal the error to Msgpack.

func (InternalServerError) MarshalJSON

func (i InternalServerError) MarshalJSON() ([]byte, error)

MarshalJSON is used to marshal the error to JSON.

func (InternalServerError) MarshalXML

func (i InternalServerError) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML is used to marshal the error to XML.

type InvalidAuth

type InvalidAuth struct {
	Message string `json:"message" xml:"message" msgpack:"message"`
}

InvalidAuth is used to define an invalid authentication error.

type InvalidBody

type InvalidBody struct {
	Message string `json:"message" xml:"message" msgpack:"message"`
}

InvalidBody is thrown when the body is invalid.

type NoPasswordAuthSupport

type NoPasswordAuthSupport struct {
	Message string `json:"message" xml:"message" msgpack:"message"`
}

NoPasswordAuthSupport is thrown when the user does not support password authentication.

type SameNode

type SameNode struct {
	Message string `json:"message" xml:"message" msgpack:"message"`
}

SameNode is used to define an error that is used when the user is on the same node for a cross-node specific request.

Jump to

Keyboard shortcuts

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