status

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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