otvet

package module
v0.0.0-...-4478070 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 2 Imported by: 0

README

otvet

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusText

func StatusText(code StatusCode) (string, *gopolutils.Exception)

Determine the string value representation of a given status code. Returns the string representation for the given status code. If the string representation of the given status code can not be determined, a ValueError is returned with an empty string.

Types

type Record

type Record[Type any] struct {
	Code StatusCode `json:"code"`
	Data Type       `json:"data"`
}

Standardized API response record.

func NewRecord

func NewRecord[Type any](code StatusCode, data Type) *Record[Type]

Construct a new record.

type StatusCode

type StatusCode = uint16

Representation of an HTTP status code.

const (
	StatusOK             StatusCode = 200 // RFC 9110, 15.3.1
	StatusCreated        StatusCode = 201 // RFC 9110, 15.3.2
	StatusAccepted       StatusCode = 202 // RFC 9110, 15.3.3
	StatusNoContent      StatusCode = 204 // RFC 9110, 15.3.5
	StatusPartialContent StatusCode = 206 // RFC 9110, 15.3.7

	StatusNotModified       StatusCode = 304 // RFC 9110, 15.4.5
	StatusUseProxy          StatusCode = 305 // RFC 9110, 15.4.6
	StatusTemporaryRedirect StatusCode = 307 // RFC 9110, 15.4.8
	StatusPermanentRedirect StatusCode = 308 // RFC 9110, 15.4.9

	StatusBadRequest            StatusCode = 400 // RFC 9110, 15.5.1
	StatusUnauthorized          StatusCode = 401 // RFC 9110, 15.5.2
	StatusPaymentRequired       StatusCode = 402 // RFC 9110, 15.5.3
	StatusForbidden             StatusCode = 403 // RFC 9110, 15.5.4
	StatusNotFound              StatusCode = 404 // RFC 9110, 15.5.5
	StatusMethodNotAllowed      StatusCode = 405 // RFC 9110, 15.5.6
	StatusNotAcceptable         StatusCode = 406 // RFC 9110, 15.5.7
	StatusRequestTimeout        StatusCode = 408 // RFC 9110, 15.5.9
	StatusConflict              StatusCode = 409 // RFC 9110, 15.5.10
	StatusRequestEntityTooLarge StatusCode = 413 // RFC 9110, 15.5.14
	StatusRequestURITooLong     StatusCode = 414 // RFC 9110, 15.5.15
	StatusUnsupportedMediaType  StatusCode = 415 // RFC 9110, 15.5.16
	StatusTeapot                StatusCode = 418 // RFC 9110, 15.5.19 (Unused)
	StatusUnprocessableEntity   StatusCode = 422 // RFC 9110, 15.5.21
	StatusLocked                StatusCode = 423 // RFC 4918, 11.3
	StatusTooManyRequests       StatusCode = 429 // RFC 6585, 4

	StatusInternalServerError           StatusCode = 500 // RFC 9110, 15.6.1
	StatusNotImplemented                StatusCode = 501 // RFC 9110, 15.6.2
	StatusBadGateway                    StatusCode = 502 // RFC 9110, 15.6.3
	StatusServiceUnavailable            StatusCode = 503 // RFC 9110, 15.6.4
	StatusGatewayTimeout                StatusCode = 504 // RFC 9110, 15.6.5
	StatusHTTPVersionNotSupported       StatusCode = 505 // RFC 9110, 15.6.6
	StatusInsufficientStorage           StatusCode = 507 // RFC 4918, 11.5
	StatusNetworkAuthenticationRequired StatusCode = 511 // RFC 6585, 6
)

Jump to

Keyboard shortcuts

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