status

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionTimeout = NewError(RequestTimeout, "connection timed out")
	ErrCloseConnection   = NewError(CloseConnection, "internal error as a signal")
	ErrShutdown          = NewError(CloseConnection, "graceful shutdown")

	ErrBadRequest          = NewError(BadRequest, "bad request")
	ErrNotFound            = NewError(NotFound, "not found")
	ErrInternalServerError = NewError(InternalServerError, "internal server error")
	// ErrMethodNotImplemented is actually uses the same error code as just ErrNotImplemented, but used
	// to explain the problem more preciously
	ErrMethodNotImplemented          = NewError(NotImplemented, "request method is not supported")
	ErrMethodNotAllowed              = NewError(MethodNotAllowed, "MethodNotAllowed")
	ErrTooLarge                      = NewError(RequestEntityTooLarge, "too large")
	ErrHeaderFieldsTooLarge          = NewError(RequestHeaderFieldsTooLarge, "header fields too large")
	ErrURITooLong                    = NewError(RequestURITooLong, "request URI too long")
	ErrURIDecoding                   = NewError(BadRequest, "invalid URI encoding")
	ErrBadQuery                      = NewError(BadRequest, "bad URL query")
	ErrUnsupportedProtocol           = NewError(HTTPVersionNotSupported, "protocol is not supported")
	ErrUnsupportedEncoding           = NewError(NotAcceptable, "content encoding is not supported")
	ErrTooManyHeaders                = NewError(RequestHeaderFieldsTooLarge, "too many headers")
	ErrUnauthorized                  = NewError(Unauthorized, "unauthorized")
	ErrPaymentRequired               = NewError(PaymentRequired, "payment required")
	ErrForbidden                     = NewError(Forbidden, "forbidden")
	ErrNotAcceptable                 = NewError(NotAcceptable, "not acceptable")
	ErrProxyAuthRequired             = NewError(ProxyAuthRequired, "proxy auth required")
	ErrRequestTimeout                = NewError(RequestTimeout, "request timeout")
	ErrConflict                      = NewError(Conflict, "conflict")
	ErrGone                          = NewError(Gone, "gone")
	ErrLengthRequired                = NewError(LengthRequired, "length required")
	ErrPreconditionFailed            = NewError(PreconditionFailed, "precondition failed")
	ErrRequestEntityTooLarge         = NewError(RequestEntityTooLarge, "request entity too large")
	ErrRequestURITooLong             = NewError(RequestURITooLong, "request URI too long")
	ErrUnsupportedMediaType          = NewError(UnsupportedMediaType, "unsupported media type")
	ErrRequestedRangeNotSatisfiable  = NewError(RequestedRangeNotSatisfiable, "requested range not satisfiable")
	ErrExpectationFailed             = NewError(ExpectationFailed, "expectation failed")
	ErrTeapot                        = NewError(Teapot, "i'm a teapot")
	ErrMisdirectedRequest            = NewError(MisdirectedRequest, "misdirected request")
	ErrUnprocessableEntity           = NewError(UnprocessableEntity, "unprocessable entity")
	ErrLocked                        = NewError(Locked, "locked")
	ErrFailedDependency              = NewError(FailedDependency, "failed dependency")
	ErrTooEarly                      = NewError(TooEarly, "too early")
	ErrUpgradeRequired               = NewError(UpgradeRequired, "upgrade required")
	ErrPreconditionRequired          = NewError(PreconditionRequired, "precondition required")
	ErrTooManyRequests               = NewError(TooManyRequests, "too many requests")
	ErrRequestHeaderFieldsTooLarge   = NewError(RequestHeaderFieldsTooLarge, "request header fields too large")
	ErrUnavailableForLegalReasons    = NewError(UnavailableForLegalReasons, "unavailable for legal reasons")
	ErrNotImplemented                = NewError(NotImplemented, "not implemented")
	ErrBadGateway                    = NewError(BadGateway, "bad gateway")
	ErrServiceUnavailable            = NewError(ServiceUnavailable, "service unavailable")
	ErrGatewayTimeout                = NewError(GatewayTimeout, "GatewayTimeout")
	ErrHTTPVersionNotSupported       = NewError(HTTPVersionNotSupported, "HTTP version not supported")
	ErrVariantAlsoNegotiates         = NewError(VariantAlsoNegotiates, "variant also negotiates")
	ErrInsufficientStorage           = NewError(InsufficientStorage, "insufficient storage")
	ErrLoopDetected                  = NewError(LoopDetected, "loop detected")
	ErrNotExtended                   = NewError(NotExtended, "not extended")
	ErrNetworkAuthenticationRequired = NewError(NetworkAuthenticationRequired, "network authentication required")
)

Functions

func CodeStatus

func CodeStatus(code Code) string

CodeStatus returns a pre-defined line with code and status text (including terminating CRLF sequence) in case code is known to server, otherwise empty line is returned

func NewError added in v0.8.1

func NewError(code Code, message string) error

Types

type Code

type Code uint16
const (
	Continue           Code = 100 // RFC 9110, 15.2.1
	SwitchingProtocols Code = 101 // RFC 9110, 15.2.2
	Processing         Code = 102 // RFC 2518, 10.1
	EarlyHints         Code = 103 // RFC 8297

	OK                   Code = 200 // RFC 9110, 15.3.1
	Created              Code = 201 // RFC 9110, 15.3.2
	Accepted             Code = 202 // RFC 9110, 15.3.3
	NonAuthoritativeInfo Code = 203 // RFC 9110, 15.3.4
	NoContent            Code = 204 // RFC 9110, 15.3.5
	ResetContent         Code = 205 // RFC 9110, 15.3.6
	PartialContent       Code = 206 // RFC 9110, 15.3.7
	MultiStatus          Code = 207 // RFC 4918, 11.1
	AlreadyReported      Code = 208 // RFC 5842, 7.1
	IMUsed               Code = 226 // RFC 3229, 10.4.1

	MultipleChoices  Code = 300 // RFC 9110, 15.4.1
	MovedPermanently Code = 301 // RFC 9110, 15.4.2
	Found            Code = 302 // RFC 9110, 15.4.3
	SeeOther         Code = 303 // RFC 9110, 15.4.4
	NotModified      Code = 304 // RFC 9110, 15.4.5
	UseProxy         Code = 305 // RFC 9110, 15.4.6

	TemporaryRedirect Code = 307 // RFC 9110, 15.4.8
	PermanentRedirect Code = 308 // RFC 9110, 15.4.9

	BadRequest                   Code = 400 // RFC 9110, 15.5.1
	Unauthorized                 Code = 401 // RFC 9110, 15.5.2
	PaymentRequired              Code = 402 // RFC 9110, 15.5.3
	Forbidden                    Code = 403 // RFC 9110, 15.5.4
	NotFound                     Code = 404 // RFC 9110, 15.5.5
	MethodNotAllowed             Code = 405 // RFC 9110, 15.5.6
	NotAcceptable                Code = 406 // RFC 9110, 15.5.7
	ProxyAuthRequired            Code = 407 // RFC 9110, 15.5.8
	RequestTimeout               Code = 408 // RFC 9110, 15.5.9
	Conflict                     Code = 409 // RFC 9110, 15.5.10
	Gone                         Code = 410 // RFC 9110, 15.5.11
	LengthRequired               Code = 411 // RFC 9110, 15.5.12
	PreconditionFailed           Code = 412 // RFC 9110, 15.5.13
	RequestEntityTooLarge        Code = 413 // RFC 9110, 15.5.14
	RequestURITooLong            Code = 414 // RFC 9110, 15.5.15
	UnsupportedMediaType         Code = 415 // RFC 9110, 15.5.16
	RequestedRangeNotSatisfiable Code = 416 // RFC 9110, 15.5.17
	ExpectationFailed            Code = 417 // RFC 9110, 15.5.18
	Teapot                       Code = 418 // RFC 9110, 15.5.19 (Unused)
	MisdirectedRequest           Code = 421 // RFC 9110, 15.5.20
	UnprocessableEntity          Code = 422 // RFC 9110, 15.5.21
	Locked                       Code = 423 // RFC 4918, 11.3
	FailedDependency             Code = 424 // RFC 4918, 11.4
	TooEarly                     Code = 425 // RFC 8470, 5.2.
	UpgradeRequired              Code = 426 // RFC 9110, 15.5.22
	PreconditionRequired         Code = 428 // RFC 6585, 3
	TooManyRequests              Code = 429 // RFC 6585, 4
	RequestHeaderFieldsTooLarge  Code = 431 // RFC 6585, 5
	CloseConnection              Code = 439
	UnavailableForLegalReasons   Code = 451 // RFC 7725, 3

	InternalServerError           Code = 500 // RFC 9110, 15.6.1
	NotImplemented                Code = 501 // RFC 9110, 15.6.2
	BadGateway                    Code = 502 // RFC 9110, 15.6.3
	ServiceUnavailable            Code = 503 // RFC 9110, 15.6.4
	GatewayTimeout                Code = 504 // RFC 9110, 15.6.5
	HTTPVersionNotSupported       Code = 505 // RFC 9110, 15.6.6
	VariantAlsoNegotiates         Code = 506 // RFC 2295, 8.1
	InsufficientStorage           Code = 507 // RFC 4918, 11.5
	LoopDetected                  Code = 508 // RFC 5842, 7.2
	NotExtended                   Code = 510 // RFC 2774, 7
	NetworkAuthenticationRequired Code = 511 // RFC 6585, 6
)

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

type HTTPError added in v0.6.1

type HTTPError struct {
	Message string
	Code    Code
}

func (HTTPError) Error added in v0.6.1

func (h HTTPError) Error() string

type Status

type Status string

func Text

func Text(code Code) Status

Text returns a text for the HTTP status code. It returns the empty string if the code is unknown.

Jump to

Keyboard shortcuts

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