status

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 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, "shutdown")
	ErrGracefulShutdown  = NewError(CloseConnection, "graceful shutdown")

	ErrBadRequest                    = NewError(BadRequest, "bad request")
	ErrTooLongRequestLine            = NewError(BadRequest, "request line is too long")
	ErrURIDecoding                   = NewError(BadRequest, "invalid URI encoding")
	ErrBadQuery                      = NewError(BadRequest, "bad URL query")
	ErrNotFound                      = NewError(NotFound, "not found")
	ErrInternalServerError           = NewError(InternalServerError, "internal server error")
	ErrNotImplemented                = NewError(NotImplemented, "not implemented")
	ErrMethodNotImplemented          = NewError(NotImplemented, "request method is not supported")
	ErrMethodNotAllowed              = NewError(MethodNotAllowed, "method not allowed")
	ErrTooLarge                      = NewError(RequestEntityTooLarge, "too large")
	ErrBodyTooLarge                  = NewError(RequestEntityTooLarge, "request body is too large")
	ErrRequestEntityTooLarge         = NewError(RequestEntityTooLarge, "request entity too large")
	ErrHeaderFieldsTooLarge          = NewError(HeaderFieldsTooLarge, "too large headers section")
	ErrHeaderKeyTooLarge             = NewError(HeaderFieldsTooLarge, "too large header key")
	ErrHeaderValueTooLarge           = NewError(HeaderFieldsTooLarge, "too large header value")
	ErrTooManyHeaders                = NewError(HeaderFieldsTooLarge, "too many headers")
	ErrRequestHeaderFieldsTooLarge   = NewError(HeaderFieldsTooLarge, "request header fields too large")
	ErrURITooLong                    = NewError(RequestURITooLong, "request URI too long")
	ErrRequestURITooLong             = NewError(RequestURITooLong, "request URI too long")
	ErrUnsupportedProtocol           = NewError(HTTPVersionNotSupported, "protocol is not supported")
	ErrHTTPVersionNotSupported       = NewError(HTTPVersionNotSupported, "HTTP version not supported")
	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")
	ErrUnsupportedMediaType          = NewError(UnsupportedMediaType, "unsupported media type")
	ErrUnsupportedEncoding           = NewError(UnsupportedMediaType, "content encoding is not supported")
	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")
	ErrUnavailableForLegalReasons    = NewError(UnavailableForLegalReasons, "unavailable for legal reasons")
	ErrBadGateway                    = NewError(BadGateway, "bad gateway")
	ErrServiceUnavailable            = NewError(ServiceUnavailable, "service unavailable")
	ErrGatewayTimeout                = NewError(GatewayTimeout, "gateway timeout")
	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 Line added in v0.15.9

func Line(code Code) string

Line returns the whole status line with code included. Be aware, that the returned string also has CRLF in the end

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
	HeaderFieldsTooLarge         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