http

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package http provides built-in reusable a problem.Definition and problem.Type for each known HTTP error. While problem generators are encouraged to define their own types etc., this package can make it easier for a generator to start utilizing problems, especially for those acting as gateways.

All definitions and types have translation keys assigned so that their details and titles can be localized respectively. However, none of the types have a URI reference as these should be specific for each generation. As such, unless specified during problem construction, these will fall back to problem.DefaultTypeURI.

Index

Constants

This section is empty.

Variables

View Source
var (
	// BadGatewayDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Bad Gateway
	// error.
	BadGatewayDefinition = problem.Definition{
		DetailKey: "problem.http.BadGatewayDefinition.detail",
		Type:      BadGateway,
	}

	// BadRequestDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Bad Request
	// error.
	BadRequestDefinition = problem.Definition{
		DetailKey: "problem.http.BadRequestDefinition.detail",
		Type:      BadRequest,
	}

	// ConflictDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Conflict
	// error.
	ConflictDefinition = problem.Definition{
		DetailKey: "problem.http.ConflictDefinition.detail",
		Type:      Conflict,
	}

	// ExpectationFailedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Expectation Failed error.
	ExpectationFailedDefinition = problem.Definition{
		DetailKey: "problem.http.ExpectationFailedDefinition.detail",
		Type:      ExpectationFailed,
	}

	// FailedDependencyDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Failed
	// Dependency error.
	FailedDependencyDefinition = problem.Definition{
		DetailKey: "problem.http.FailedDependencyDefinition.detail",
		Type:      FailedDependency,
	}

	// ForbiddenDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Forbidden
	// error.
	ForbiddenDefinition = problem.Definition{
		DetailKey: "problem.http.ForbiddenDefinition.detail",
		Type:      Forbidden,
	}

	// GatewayTimeoutDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Gateway
	// Timeout error.
	GatewayTimeoutDefinition = problem.Definition{
		DetailKey: "problem.http.GatewayTimeoutDefinition.detail",
		Type:      GatewayTimeout,
	}

	// GoneDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Gone error.
	GoneDefinition = problem.Definition{
		DetailKey: "problem.http.GoneDefinition.detail",
		Type:      Gone,
	}

	// HTTPVersionNotSupportedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Version Not Supported error.
	HTTPVersionNotSupportedDefinition = problem.Definition{
		DetailKey: "problem.http.HTTPVersionNotSupportedDefinition.detail",
		Type:      HTTPVersionNotSupported,
	}

	// InsufficientStorageDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Insufficient Storage error.
	InsufficientStorageDefinition = problem.Definition{
		DetailKey: "problem.http.InsufficientStorageDefinition.detail",
		Type:      InsufficientStorage,
	}

	// InternalServerDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Internal
	// Server error.
	InternalServerDefinition = problem.Definition{
		DetailKey: "problem.http.InternalServerDefinition.detail",
		Type:      InternalServer,
	}

	// LengthRequiredDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Length
	// Required error.
	LengthRequiredDefinition = problem.Definition{
		DetailKey: "problem.http.LengthRequiredDefinition.detail",
		Type:      LengthRequired,
	}

	// LockedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Locked error.
	LockedDefinition = problem.Definition{
		DetailKey: "problem.http.LockedDefinition.detail",
		Type:      Locked,
	}

	// LoopDetectedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Loop
	// Detected error.
	LoopDetectedDefinition = problem.Definition{
		DetailKey: "problem.http.LoopDetectedDefinition.detail",
		Type:      LoopDetected,
	}

	// MethodNotAllowedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Method
	// Not Allowed error.
	MethodNotAllowedDefinition = problem.Definition{
		DetailKey: "problem.http.MethodNotAllowedDefinition.detail",
		Type:      MethodNotAllowed,
	}

	// MisdirectedRequestDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Misdirected Request error.
	MisdirectedRequestDefinition = problem.Definition{
		DetailKey: "problem.http.MisdirectedRequestDefinition.detail",
		Type:      MisdirectedRequest,
	}

	// NetworkAuthenticationRequiredDefinition is a built-in reusable problem.Definition that may be used to represent
	// an HTTP Network Authentication Required error.
	NetworkAuthenticationRequiredDefinition = problem.Definition{
		DetailKey: "problem.http.NetworkAuthenticationRequiredDefinition.detail",
		Type:      NetworkAuthenticationRequired,
	}

	// NotAcceptableDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Not
	// Acceptable error.
	NotAcceptableDefinition = problem.Definition{
		DetailKey: "problem.http.NotAcceptableDefinition.detail",
		Type:      NotAcceptable,
	}

	// NotFoundDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Not Found
	// error.
	NotFoundDefinition = problem.Definition{
		DetailKey: "problem.http.NotFoundDefinition.detail",
		Type:      NotFound,
	}

	// NotExtendedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Not
	// Extended error.
	NotExtendedDefinition = problem.Definition{
		DetailKey: "problem.http.NotExtendedDefinition.detail",
		Type:      NotExtended,
	}

	// NotImplementedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Not
	// Implemented error.
	NotImplementedDefinition = problem.Definition{
		DetailKey: "problem.http.NotImplementedDefinition.detail",
		Type:      NotImplemented,
	}

	// PaymentRequiredDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Payment
	// Required error.
	PaymentRequiredDefinition = problem.Definition{
		DetailKey: "problem.http.PaymentRequiredDefinition.detail",
		Type:      PaymentRequired,
	}

	// PreconditionFailedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Precondition Failed error.
	PreconditionFailedDefinition = problem.Definition{
		DetailKey: "problem.http.PreconditionFailedDefinition.detail",
		Type:      PreconditionFailed,
	}

	// PreconditionRequiredDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Precondition Required error.
	PreconditionRequiredDefinition = problem.Definition{
		DetailKey: "problem.http.PreconditionRequiredDefinition.detail",
		Type:      PreconditionRequired,
	}

	// ProxyAuthRequiredDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Proxy
	// Authentication Required error.
	ProxyAuthRequiredDefinition = problem.Definition{
		DetailKey: "problem.http.ProxyAuthRequiredDefinition.detail",
		Type:      ProxyAuthRequired,
	}

	// RequestEntityTooLargeDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Request Entity Too Large error.
	RequestEntityTooLargeDefinition = problem.Definition{
		DetailKey: "problem.http.RequestEntityTooLargeDefinition.detail",
		Type:      RequestEntityTooLarge,
	}

	// RequestHeaderFieldsTooLargeDefinition is a built-in reusable problem.Definition that may be used to represent an
	// HTTP Request Header Fields Too Large error.
	RequestHeaderFieldsTooLargeDefinition = problem.Definition{
		DetailKey: "problem.http.RequestHeaderFieldsTooLargeDefinition.detail",
		Type:      RequestHeaderFieldsTooLarge,
	}

	// RequestTimeoutDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Request
	// Timeout error.
	RequestTimeoutDefinition = problem.Definition{
		DetailKey: "problem.http.RequestTimeoutDefinition.detail",
		Type:      RequestTimeout,
	}

	// RequestURITooLongDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Request URI Too Longer error.
	RequestURITooLongDefinition = problem.Definition{
		DetailKey: "problem.http.RequestURITooLongDefinition.detail",
		Type:      RequestURITooLong,
	}

	// RequestedRangeNotSatisfiableDefinition is a built-in reusable problem.Definition that may be used to represent an
	// HTTP Requested Range Not Satisfiable error.
	RequestedRangeNotSatisfiableDefinition = problem.Definition{
		DetailKey: "problem.http.RequestedRangeNotSatisfiableDefinition.detail",
		Type:      RequestedRangeNotSatisfiable,
	}

	// ServiceUnavailableDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Service Unavailable error.
	ServiceUnavailableDefinition = problem.Definition{
		DetailKey: "problem.http.ServiceUnavailableDefinition.detail",
		Type:      ServiceUnavailable,
	}

	// TeapotDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP I'm a teapot
	// error.
	TeapotDefinition = problem.Definition{
		DetailKey: "problem.http.TeapotDefinition.detail",
		Type:      Teapot,
	}

	// TooEarlyDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Too Early
	// error.
	TooEarlyDefinition = problem.Definition{
		DetailKey: "problem.http.TooEarlyDefinition.detail",
		Type:      TooEarly,
	}

	// TooManyRequestsDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Too
	// Many Requests error.
	TooManyRequestsDefinition = problem.Definition{
		DetailKey: "problem.http.TooManyRequestsDefinition.detail",
		Type:      TooManyRequests,
	}

	// UnauthorizedDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Unauthorized error.
	UnauthorizedDefinition = problem.Definition{
		DetailKey: "problem.http.UnauthorizedDefinition.detail",
		Type:      Unauthorized,
	}

	// UnavailableForLegalReasonsDefinition is a built-in reusable problem.Definition that may be used to represent an
	// HTTP Unavailable For Legal Reasons error.
	UnavailableForLegalReasonsDefinition = problem.Definition{
		DetailKey: "problem.http.UnavailableForLegalReasonsDefinition.detail",
		Type:      UnavailableForLegalReasons,
	}

	// UnprocessableEntityDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Unprocessable Entity error.
	UnprocessableEntityDefinition = problem.Definition{
		DetailKey: "problem.http.UnprocessableEntityDefinition.detail",
		Type:      UnprocessableEntity,
	}

	// UnsupportedMediaTypeDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Unsupported Media Type error.
	UnsupportedMediaTypeDefinition = problem.Definition{
		DetailKey: "problem.http.UnsupportedMediaTypeDefinition.detail",
		Type:      UnsupportedMediaType,
	}

	// UpgradeRequiredDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP Upgrade
	// Required error.
	UpgradeRequiredDefinition = problem.Definition{
		DetailKey: "problem.http.UpgradeRequiredDefinition.detail",
		Type:      UpgradeRequired,
	}

	// VariantAlsoNegotiatesDefinition is a built-in reusable problem.Definition that may be used to represent an HTTP
	// Variant Also Negotiates error.
	VariantAlsoNegotiatesDefinition = problem.Definition{
		DetailKey: "problem.http.VariantAlsoNegotiatesDefinition.detail",
		Type:      VariantAlsoNegotiates,
	}
)
View Source
var (
	// BadGateway is a built-in reusable problem.Type that may be used to represent an HTTP Bad Gateway error.
	BadGateway = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusBadGateway,
		Title:    http.StatusText(http.StatusBadGateway),
		TitleKey: "problem.http.BadGateway.title",
	}

	// BadRequest is a built-in reusable problem.Type that may be used to represent an HTTP Bad Request error.
	BadRequest = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusBadRequest,
		Title:    http.StatusText(http.StatusBadRequest),
		TitleKey: "problem.http.BadRequest.title",
	}

	// Conflict is a built-in reusable problem.Type that may be used to represent an HTTP Conflict error.
	Conflict = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusConflict,
		Title:    http.StatusText(http.StatusConflict),
		TitleKey: "problem.http.Conflict.title",
	}

	// ExpectationFailed is a built-in reusable problem.Type that may be used to represent an HTTP Expectation Failed
	// error.
	ExpectationFailed = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusExpectationFailed,
		Title:    http.StatusText(http.StatusExpectationFailed),
		TitleKey: "problem.http.ExpectationFailed.title",
	}

	// FailedDependency is a built-in reusable problem.Type that may be used to represent an HTTP Failed Dependency
	// error.
	FailedDependency = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusFailedDependency,
		Title:    http.StatusText(http.StatusFailedDependency),
		TitleKey: "problem.http.FailedDependency.title",
	}

	// Forbidden is a built-in reusable problem.Type that may be used to represent an HTTP Forbidden error.
	Forbidden = problem.Type{
		LogLevel: problem.LogLevelWarn,
		Status:   http.StatusForbidden,
		Title:    http.StatusText(http.StatusForbidden),
		TitleKey: "problem.http.Forbidden.title",
	}

	// GatewayTimeout is a built-in reusable problem.Type that may be used to represent an HTTP Gateway Timeout error.
	GatewayTimeout = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusGatewayTimeout,
		Title:    http.StatusText(http.StatusGatewayTimeout),
		TitleKey: "problem.http.GatewayTimeout.title",
	}

	// Gone is a built-in reusable problem.Type that may be used to represent an HTTP Gone error.
	Gone = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusGone,
		Title:    http.StatusText(http.StatusGone),
		TitleKey: "problem.http.Gone.title",
	}

	// HTTPVersionNotSupported is a built-in reusable problem.Type that may be used to represent an HTTP Version Not
	// Supported error.
	HTTPVersionNotSupported = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusHTTPVersionNotSupported,
		Title:    http.StatusText(http.StatusHTTPVersionNotSupported),
		TitleKey: "problem.http.HTTPVersionNotSupported.title",
	}

	// InsufficientStorage is a built-in reusable problem.Type that may be used to represent an HTTP Insufficient
	// Storage error.
	InsufficientStorage = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusInsufficientStorage,
		Title:    http.StatusText(http.StatusInsufficientStorage),
		TitleKey: "problem.http.InsufficientStorage.title",
	}

	// InternalServer is a built-in reusable problem.Type that may be used to represent an HTTP Internal Server error.
	InternalServer = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusInternalServerError,
		Title:    http.StatusText(http.StatusInternalServerError),
		TitleKey: "problem.http.InternalServer.title",
	}

	// LengthRequired is a built-in reusable problem.Type that may be used to represent an HTTP Length Required error.
	LengthRequired = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusLengthRequired,
		Title:    http.StatusText(http.StatusLengthRequired),
		TitleKey: "problem.http.LengthRequired.title",
	}

	// Locked is a built-in reusable problem.Type that may be used to represent an HTTP Locked error.
	Locked = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusLocked,
		Title:    http.StatusText(http.StatusLocked),
		TitleKey: "problem.http.Locked.title",
	}

	// LoopDetected is a built-in reusable problem.Type that may be used to represent an HTTP Loop Detected error.
	LoopDetected = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusLoopDetected,
		Title:    http.StatusText(http.StatusLoopDetected),
		TitleKey: "problem.http.LoopDetected.title",
	}

	// MethodNotAllowed is a built-in reusable problem.Type that may be used to represent an HTTP Method Not Allowed
	// error.
	MethodNotAllowed = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusMethodNotAllowed,
		Title:    http.StatusText(http.StatusMethodNotAllowed),
		TitleKey: "problem.http.MethodNotAllowed.title",
	}

	// MisdirectedRequest is a built-in reusable problem.Type that may be used to represent an HTTP Misdirected Request
	// error.
	MisdirectedRequest = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusMisdirectedRequest,
		Title:    http.StatusText(http.StatusMisdirectedRequest),
		TitleKey: "problem.http.MisdirectedRequest.title",
	}

	// NetworkAuthenticationRequired is a built-in reusable problem.Type that may be used to represent an HTTP Network
	// Authentication Required error.
	NetworkAuthenticationRequired = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusNetworkAuthenticationRequired,
		Title:    http.StatusText(http.StatusNetworkAuthenticationRequired),
		TitleKey: "problem.http.NetworkAuthenticationRequired.title",
	}

	// NotAcceptable is a built-in reusable problem.Type that may be used to represent an HTTP Not Acceptable error.
	NotAcceptable = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusNotAcceptable,
		Title:    http.StatusText(http.StatusNotAcceptable),
		TitleKey: "problem.http.NotAcceptable.title",
	}

	// NotExtended is a built-in reusable problem.Type that may be used to represent an HTTP Not Extended error.
	NotExtended = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusNotExtended,
		Title:    http.StatusText(http.StatusNotExtended),
		TitleKey: "problem.http.NotExtended.title",
	}

	// NotFound is a built-in reusable problem.Type that may be used to represent an HTTP Not Found error.
	NotFound = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusNotFound,
		Title:    http.StatusText(http.StatusNotFound),
		TitleKey: "problem.http.NotFound.title",
	}

	// NotImplemented is a built-in reusable problem.Type that may be used to represent an HTTP Not Implemented error.
	NotImplemented = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusNotImplemented,
		Title:    http.StatusText(http.StatusNotImplemented),
		TitleKey: "problem.http.NotImplemented.title",
	}

	// PaymentRequired is a built-in reusable problem.Type that may be used to represent an HTTP Payment Required error.
	PaymentRequired = problem.Type{
		LogLevel: problem.LogLevelWarn,
		Status:   http.StatusPaymentRequired,
		Title:    http.StatusText(http.StatusPaymentRequired),
		TitleKey: "problem.http.PaymentRequired.title",
	}

	// PreconditionFailed is a built-in reusable problem.Type that may be used to represent an HTTP Precondition Failed
	// error.
	PreconditionFailed = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusPreconditionFailed,
		Title:    http.StatusText(http.StatusPreconditionFailed),
		TitleKey: "problem.http.PreconditionFailed.title",
	}

	// PreconditionRequired is a built-in reusable problem.Type that may be used to represent an HTTP Precondition
	// Required error.
	PreconditionRequired = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusPreconditionRequired,
		Title:    http.StatusText(http.StatusPreconditionRequired),
		TitleKey: "problem.http.PreconditionRequired.title",
	}

	// ProxyAuthRequired is a built-in reusable problem.Type that may be used to represent an HTTP Proxy Authentication
	// Required error.
	ProxyAuthRequired = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusProxyAuthRequired,
		Title:    http.StatusText(http.StatusProxyAuthRequired),
		TitleKey: "problem.http.ProxyAuthRequired.title",
	}

	// RequestEntityTooLarge is a built-in reusable problem.Type that may be used to represent an HTTP Request Entity
	// Too Large error.
	RequestEntityTooLarge = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusRequestEntityTooLarge,
		Title:    http.StatusText(http.StatusRequestEntityTooLarge),
		TitleKey: "problem.http.RequestEntityTooLarge.title",
	}

	// RequestHeaderFieldsTooLarge is a built-in reusable problem.Type that may be used to represent an HTTP Request
	// Header Fields Too Large error.
	RequestHeaderFieldsTooLarge = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusRequestHeaderFieldsTooLarge,
		Title:    http.StatusText(http.StatusRequestHeaderFieldsTooLarge),
		TitleKey: "problem.http.RequestHeaderFieldsTooLarge.title",
	}

	// RequestTimeout is a built-in reusable problem.Type that may be used to represent an HTTP Request Timeout error.
	RequestTimeout = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusRequestTimeout,
		Title:    http.StatusText(http.StatusRequestTimeout),
		TitleKey: "problem.http.RequestTimeout.title",
	}

	// RequestURITooLong is a built-in reusable problem.Type that may be used to represent an HTTP Request URI Too Long
	// error.
	RequestURITooLong = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusRequestURITooLong,
		Title:    http.StatusText(http.StatusRequestURITooLong),
		TitleKey: "problem.http.RequestURITooLong.title",
	}

	// RequestedRangeNotSatisfiable is a built-in reusable problem.Type that may be used to represent an HTTP Requested
	// Range Not Satisfiable error.
	RequestedRangeNotSatisfiable = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusRequestedRangeNotSatisfiable,
		Title:    http.StatusText(http.StatusRequestedRangeNotSatisfiable),
		TitleKey: "problem.http.RequestedRangeNotSatisfiable.title",
	}

	// ServiceUnavailable is a built-in reusable problem.Type that may be used to represent an HTTP Service Unavailable
	// error.
	ServiceUnavailable = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusServiceUnavailable,
		Title:    http.StatusText(http.StatusServiceUnavailable),
		TitleKey: "problem.http.ServiceUnavailable.title",
	}

	// Teapot is a built-in reusable problem.Type that may be used to represent an HTTP I'm a teapot error.
	Teapot = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusTeapot,
		Title:    http.StatusText(http.StatusTeapot),
		TitleKey: "problem.http.Teapot.title",
	}

	// TooEarly is a built-in reusable problem.Type that may be used to represent an HTTP Too Early error.
	TooEarly = problem.Type{
		LogLevel: problem.LogLevelWarn,
		Status:   http.StatusTooEarly,
		Title:    http.StatusText(http.StatusTooEarly),
		TitleKey: "problem.http.TooEarly.title",
	}

	// TooManyRequests is a built-in reusable problem.Type that may be used to represent an HTTP Too Many Requests
	// error.
	TooManyRequests = problem.Type{
		LogLevel: problem.LogLevelWarn,
		Status:   http.StatusTooManyRequests,
		Title:    http.StatusText(http.StatusTooManyRequests),
		TitleKey: "problem.http.TooManyRequests.title",
	}

	// Unauthorized is a built-in reusable problem.Type that may be used to represent an HTTP Unauthorized error.
	Unauthorized = problem.Type{
		LogLevel: problem.LogLevelWarn,
		Status:   http.StatusUnauthorized,
		Title:    http.StatusText(http.StatusUnauthorized),
		TitleKey: "problem.http.Unauthorized.title",
	}

	// UnavailableForLegalReasons is a built-in reusable problem.Type that may be used to represent an HTTP Unavailable
	// For Legal Reasons error.
	UnavailableForLegalReasons = problem.Type{
		LogLevel: problem.LogLevelWarn,
		Status:   http.StatusUnavailableForLegalReasons,
		Title:    http.StatusText(http.StatusUnavailableForLegalReasons),
		TitleKey: "problem.http.UnavailableForLegalReasons.title",
	}

	// UnprocessableEntity is a built-in reusable problem.Type that may be used to represent an HTTP Unprocessable
	// Entity error.
	UnprocessableEntity = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusUnprocessableEntity,
		Title:    http.StatusText(http.StatusUnprocessableEntity),
		TitleKey: "problem.http.UnprocessableEntity.title",
	}

	// UnsupportedMediaType is a built-in reusable problem.Type that may be used to represent an HTTP Unsupported Media
	// Type error.
	UnsupportedMediaType = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusUnsupportedMediaType,
		Title:    http.StatusText(http.StatusUnsupportedMediaType),
		TitleKey: "problem.http.UnsupportedMediaType.title",
	}

	// UpgradeRequired is a built-in reusable problem.Type that may be used to represent an HTTP Upgrade Required error.
	UpgradeRequired = problem.Type{
		LogLevel: problem.LogLevelDebug,
		Status:   http.StatusUpgradeRequired,
		Title:    http.StatusText(http.StatusUpgradeRequired),
		TitleKey: "problem.http.UpgradeRequired.title",
	}

	// VariantAlsoNegotiates is a built-in reusable problem.Type that may be used to represent an HTTP Variant Also
	// Negotiates error.
	VariantAlsoNegotiates = problem.Type{
		LogLevel: problem.LogLevelError,
		Status:   http.StatusVariantAlsoNegotiates,
		Title:    http.StatusText(http.StatusVariantAlsoNegotiates),
		TitleKey: "problem.http.VariantAlsoNegotiates.title",
	}
)

Functions

func StatusDefinition

func StatusDefinition(code int) problem.Definition

StatusDefinition returns a problem.Definition for the given HTTP status code or an empty/zero problem.Definition if code is unknown.

For example;

StatusDefinition(400)  // BadRequestDefinition{}
StatusDefinition(404)  // NotFoundDefinition{}
StatusDefinition(999)  // problem.Definition{}

func StatusDefinitionOrElse

func StatusDefinitionOrElse(code int, defaultDefinition problem.Definition) problem.Definition

StatusDefinitionOrElse returns a problem.Definition for the given HTTP status code or defaultDefinition if code is unknown.

For example;

defaultDef := InternalServerDefinition{}
StatusDefinitionOrElse(400, defaultDef)  // BadRequestDefinition{}
StatusDefinitionOrElse(404, defaultDef)  // NotFoundDefinition{}
StatusDefinitionOrElse(999, defaultDef)  // InternalServerDefinition{}

func StatusType

func StatusType(code int) problem.Type

StatusType returns a problem.Type for the given HTTP status code or an empty/zero problem.Type if code is unknown.

For example;

StatusType(400)  // BadRequest{}
StatusType(404)  // NotFound{}
StatusType(999)  // problem.Type{}

func StatusTypeOrElse

func StatusTypeOrElse(code int, defaultType problem.Type) problem.Type

StatusTypeOrElse returns a problem.Type for the given HTTP status code or defaultType if code is unknown.

For example;

defaultType := InternalServer{}
StatusTypeOrElse(400, defaultType)  // BadRequest{}
StatusTypeOrElse(404, defaultType)  // NotFound{}
StatusTypeOrElse(999, defaultType)  // InternalServer{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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