Documentation ¶
Index ¶
Constants ¶
const ( StatusInvalid Status = iota StatusContinue = 100 // RFC 7231, 6.2.1 StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2 StatusProcessing = 102 // RFC 2518, 10.1 StatusEarlyHints = 103 // RFC 8297 StatusOK = 200 // RFC 7231, 6.3.1 StatusCreated = 201 // RFC 7231, 6.3.2 StatusAccepted = 202 // RFC 7231, 6.3.3 StatusNonAuthoritativeInfo = 203 // RFC 7231, 6.3.4 StatusNoContent = 204 // RFC 7231, 6.3.5 StatusResetContent = 205 // RFC 7231, 6.3.6 StatusPartialContent = 206 // RFC 7233, 4.1 StatusMultiStatus = 207 // RFC 4918, 11.1 StatusAlreadyReported = 208 // RFC 5842, 7.1 StatusIMUsed = 226 // RFC 3229, 10.4.1 StatusMultipleChoices = 300 // RFC 9110, 15.4.1 StatusMovedPermanently = 301 // RFC 9110, 15.4.2 StatusFound = 302 // RFC 9110, 15.4.3 StatusSeeOther = 303 // RFC 9110, 15.4.4 StatusNotModified = 304 // RFC 9110, 15.4.5 StatusUseProxy = 305 // RFC 9110, 15.4.6 StatusTemporaryRedirect = 307 // RFC 9110, 15.4.8 StatusPermanentRedirect = 308 // RFC 9110, 15.4.9 StatusBadRequest = 400 // RFC 9110, 15.5.1 StatusPaymentRequired = 402 // RFC 9110, 15.5.3 StatusForbidden = 403 // RFC 9110, 15.5.4 StatusNotFound = 404 // RFC 9110, 15.5.5 StatusMethodNotAllowed = 405 // RFC 9110, 15.5.6 StatusNotAcceptable = 406 // RFC 9110, 15.5.7 StatusProxyAuthRequired = 407 // RFC 9110, 15.5.8 StatusRequestTimeout = 408 // RFC 9110, 15.5.9 StatusConflict = 409 // RFC 9110, 15.5.10 StatusGone = 410 // RFC 9110, 15.5.11 StatusLengthRequired = 411 // RFC 9110, 15.5.12 StatusPreconditionFailed = 412 // RFC 9110, 15.5.13 StatusRequestEntityTooLarge = 413 // RFC 9110, 15.5.14 StatusRequestURITooLong = 414 // RFC 9110, 15.5.15 StatusUnsupportedMediaType = 415 // RFC 9110, 15.5.16 StatusRequestedRangeNotSatisfiable = 416 // RFC 9110, 15.5.17 StatusExpectationFailed = 417 // RFC 9110, 15.5.18 StatusTeapot = 418 // RFC 9110, 15.5.19 (Unused) StatusMisdirectedRequest = 421 // RFC 9110, 15.5.20 StatusUnprocessableEntity = 422 // RFC 9110, 15.5.21 StatusLocked = 423 // RFC 4918, 11.3 StatusFailedDependency = 424 // RFC 4918, 11.4 StatusTooEarly = 425 // RFC 8470, 5.2. StatusUpgradeRequired = 426 // RFC 9110, 15.5.22 StatusPreconditionRequired = 428 // RFC 6585, 3 StatusTooManyRequests = 429 // RFC 6585, 4 StatusRequestHeaderFieldsTooLarge = 431 // RFC 6585, 5 StatusInternalServerError = 500 // RFC 9110, 15.6.1 StatusNotImplemented = 501 // RFC 9110, 15.6.2 StatusBadGateway = 502 // RFC 9110, 15.6.3 StatusGatewayTimeout = 504 // RFC 9110, 15.6.5 StatusHTTPVersionNotSupported = 505 // RFC 9110, 15.6.6 StatusVariantAlsoNegotiates = 506 // RFC 2295, 8.1 StatusInsufficientStorage = 507 // RFC 4918, 11.5 StatusLoopDetected = 508 // RFC 5842, 7.2 StatusNotExtended = 510 // RFC 2774, 7 StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6 )
Variables ¶
var ( // HeaderNames is a map of Header to string. HeaderNames = map[Header]string{}/* 119 elements not displayed */ // ErrHeaderInvalid is returned if the HTTP header is invalid. ErrHeaderInvalid = errors.New("invalid http header") )
var ( // MethodNames is a map of Method to string. MethodNames = map[Method]string{ MethodGet: "GET", MethodHead: "HEAD", MethodPost: "POST", MethodPut: "PUT", MethodDelete: "DELETE", MethodConnect: "CONNECT", MethodOptions: "OPTIONS", MethodTrace: "TRACE", MethodPatch: "PATCH", } // ErrMethodInvalid is returned if the HTTP method is invalid. ErrMethodInvalid = errors.New("invalid http method") )
var ( // StatusNames is a map of Status to string. StatusNames = map[Status]string{ StatusContinue: "Continue", StatusSwitchingProtocols: "Switching Protocols", StatusProcessing: "Processing", StatusEarlyHints: "Early Hints", StatusOK: "OK", StatusCreated: "Created", StatusAccepted: "Accepted", StatusNonAuthoritativeInfo: "Non-Authoritative Information", StatusNoContent: "No Content", StatusResetContent: "Reset Content", StatusPartialContent: "Partial Content", StatusMultiStatus: "Multi-Status", StatusAlreadyReported: "Already Reported", StatusIMUsed: "IM Used", StatusMultipleChoices: "Multiple Choices", StatusMovedPermanently: "Moved Permanently", StatusFound: "Found", StatusSeeOther: "See Other", StatusNotModified: "Not Modified", StatusUseProxy: "Use Proxy", StatusTemporaryRedirect: "Temporary Redirect", StatusPermanentRedirect: "Permanent Redirect", StatusBadRequest: "Bad Request", StatusUnauthorized: "Unauthorized", StatusPaymentRequired: "Payment Required", StatusForbidden: "Forbidden", StatusNotFound: "Not Found", StatusMethodNotAllowed: "Method Not Allowed", StatusNotAcceptable: "Not Acceptable", StatusProxyAuthRequired: "Proxy Authentication Required", StatusRequestTimeout: "Request Timeout", StatusConflict: "Conflict", StatusGone: "Gone", StatusLengthRequired: "Length Required", StatusPreconditionFailed: "Precondition Failed", StatusRequestEntityTooLarge: "Request Entity Too Large", StatusRequestURITooLong: "Request URI Too Long", StatusUnsupportedMediaType: "Unsupported Media Type", StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable", StatusExpectationFailed: "Expectation Failed", StatusTeapot: "I'm a teapot", StatusMisdirectedRequest: "Misdirected Request", StatusUnprocessableEntity: "Unprocessable Entity", StatusLocked: "Locked", StatusFailedDependency: "Failed Dependency", StatusTooEarly: "Too Early", StatusUpgradeRequired: "Upgrade Required", StatusPreconditionRequired: "Precondition Required", StatusTooManyRequests: "Too Many Requests", StatusRequestHeaderFieldsTooLarge: "Request Header Fields Too Large", StatusUnavailableForLegalReasons: "Unavailable For Legal Reasons", StatusInternalServerError: "Internal Server Error", StatusNotImplemented: "Not Implemented", StatusBadGateway: "Bad Gateway", StatusServiceUnavailable: "Service Unavailable", StatusGatewayTimeout: "Gateway Timeout", StatusHTTPVersionNotSupported: "HTTP Version Not Supported", StatusVariantAlsoNegotiates: "Variant Also Negotiates", StatusInsufficientStorage: "Insufficient Storage", StatusLoopDetected: "Loop Detected", StatusNotExtended: "Not Extended", StatusNetworkAuthenticationRequired: "Network Authentication Required", } // ErrStatusInvalid is returned if the HTTP status is invalid. ErrStatusInvalid = errors.New("invalid http status") )
Functions ¶
This section is empty.
Types ¶
type Error ¶ added in v1.2.3
type Error struct { Status Status `json:"status" yaml:"Status"` Message string `json:"message" yaml:"Message"` }
Error represents an HTTP error.
func (*Error) StatusCode ¶ added in v1.2.3
StatusCode returns the HTTP status code.
type Header ¶ added in v1.2.2
type Header uint16
Header defines an HTTP header.
const ( HeaderInvalid Header = iota // // Authentication HeaderAuthorization // RFC 7235, 4.2 HeaderProxyAuthenticate HeaderProxyAuthorization HeaderWWWAuthenticate // Caching HeaderAge HeaderCacheControl HeaderClearSiteData HeaderExpires HeaderPragma HeaderWarning // Client hints HeaderAcceptCH HeaderAcceptCHLifetime HeaderContentDPR HeaderDPR HeaderEarlyData HeaderSaveData HeaderViewportWidth HeaderWidth // Conditionals HeaderETag HeaderIfMatch HeaderIfModifiedSince HeaderIfNoneMatch HeaderIfUnmodifiedSince HeaderLastModified HeaderVary // Connection management HeaderConnection HeaderKeepAlive HeaderProxyConnection // Content negotiation HeaderAccept HeaderAcceptCharset HeaderAcceptEncoding HeaderAcceptLanguage // Controls HeaderCookie HeaderExpect HeaderMaxForwards HeaderSetCookie // CORS HeaderAccessControlAllowCredentials HeaderAccessControlAllowHeaders HeaderAccessControlAllowMethods HeaderAccessControlAllowOrigin HeaderAccessControlExposeHeaders HeaderAccessControlMaxAge HeaderAccessControlRequestHeaders HeaderAccessControlRequestMethod HeaderOrigin HeaderTimingAllowOrigin HeaderXPermittedCrossDomainPolicies // Do Not Track HeaderDNT HeaderTk // Downloads HeaderContentDisposition // Message body information HeaderContentEncoding HeaderContentLanguage HeaderContentLength HeaderContentLocation HeaderContentType // Proxies HeaderForwarded HeaderVia HeaderXForwardedFor HeaderXForwardedHost HeaderXForwardedProto // Redirects HeaderLocation // Request context HeaderFrom HeaderHost HeaderReferer HeaderReferrerPolicy HeaderUserAgent // Response context HeaderAllow HeaderServer // Range requests HeaderAcceptRanges HeaderContentRange HeaderIfRange HeaderRange // Security HeaderContentSecurityPolicy HeaderContentSecurityPolicyReportOnly HeaderCrossOriginResourcePolicy HeaderExpectCT HeaderFeaturePolicy HeaderPublicKeyPins HeaderPublicKeyPinsReportOnly HeaderStrictTransportSecurity HeaderUpgradeInsecureRequests HeaderXContentTypeOptions HeaderXDownloadOptions HeaderXFrameOptions HeaderXPoweredBy HeaderXXSSProtection // Server-sent event HeaderLastEventID HeaderNEL HeaderPingFrom HeaderPingTo HeaderReportTo // Transfer coding HeaderTE HeaderTrailer HeaderTransferEncoding // WebSockets HeaderSecWebSocketAccept HeaderSecWebSocketExtensions HeaderSecWebSocketKey HeaderSecWebSocketProtocol HeaderSecWebSocketVersion // Other HeaderAcceptPatch HeaderAcceptPushPolicy HeaderAcceptSignature HeaderAltSvc HeaderDate HeaderIndex HeaderLargeAllocation HeaderLink HeaderPushPolicy HeaderRetryAfter HeaderServerTiming HeaderSignature HeaderSignedHeaders HeaderSourceMap HeaderUpgrade HeaderXDNSPrefetchControl HeaderXPingback HeaderXRequestedWith HeaderXRobotsTag HeaderXUACompatible )
Common HTTP headers, these are defined in RFC 7231 section 4.3.
func MustParseHeader ¶ added in v1.2.2
MustParseHeader parses header string or panics.
func ParseHeader ¶ added in v1.2.2
ParseHeader parses header string.
func (Header) MarshalJSON ¶ added in v1.2.2
MarshalJSON header to json
func (*Header) UnmarshalJSON ¶ added in v1.2.2
UnmarshalJSON header from json
type IError ¶ added in v1.2.3
type IError interface { error // StatusCode returns the HTTP status code of the error StatusCode() Status }
IError defines the interface for an HTTP error.
type Method ¶
type Method uint8
Method defines an HTTP method.
const ( MethodInvalid Method = iota // MethodGet // RFC 7231, 4.3.1 MethodHead // RFC 7231, 4.3.2 MethodPost // RFC 7231, 4.3.3 MethodPut // RFC 7231, 4.3.4 MethodDelete // RFC 7231, 4.3.5 MethodConnect // RFC 7231, 4.3.6 MethodOptions // RFC 7231, 4.3.7 MethodTrace // RFC 7231, 4.3.8 MethodPatch // RFC 5789 )
Common HTTP methods, these are defined in RFC 7231 section 4.3.
func MustParseMethod ¶
MustParseMethod parses method string or panics.
func (Method) MarshalJSON ¶
MarshalJSON method to json
func (*Method) UnmarshalJSON ¶
UnmarshalJSON method from json
type Status ¶ added in v1.2.2
type Status uint16
Status defines an HTTP status.
func MustParseStatus ¶ added in v1.2.2
MustParseStatus parses status string or panics.
func ParseStatus ¶ added in v1.2.2
ParseStatus parses status string.
func (Status) MarshalJSON ¶ added in v1.2.2
MarshalJSON status to json
func (*Status) UnmarshalJSON ¶ added in v1.2.2
UnmarshalJSON status from json