HttpStatus
Named HTTP status codes for the unstable HTTP modules.
This module centralizes the mapping from literal names of the known HTTP
status codes, such as "OK" and "Conflict", to their numeric codes. Use
fromLiteral to obtain a status code from a literal name instead of
remembering raw numbers.
Constructors
fromLiteral
Added in v4.0.0
Source
Returns the numeric HTTP status code for a literal name.
Signature
declare function fromLiteral<L extends "NotFound" | "Forbidden" | "Unauthorized" | "InternalServerError" | "Continue" | "SwitchingProtocols" | "Processing" | "EarlyHints" | "OK" | "Ok" | "Created" | "Accepted" | "NonAuthoritativeInformation" | "NoContent" | "ResetContent" | "PartialContent" | "MultiStatus" | "AlreadyReported" | "ImUsed" | "MultipleChoices" | "MovedPermanently" | "Found" | "SeeOther" | "NotModified" | "TemporaryRedirect" | "PermanentRedirect" | "BadRequest" | "PaymentRequired" | "MethodNotAllowed" | "NotAcceptable" | "ProxyAuthenticationRequired" | "RequestTimeout" | "Conflict" | "Gone" | "LengthRequired" | "PreconditionFailed" | "PayloadTooLarge" | "UriTooLong" | "UnsupportedMediaType" | "RangeNotSatisfiable" | "ExpectationFailed" | "ImATeapot" | "MisdirectedRequest" | "UnprocessableEntity" | "Locked" | "FailedDependency" | "TooEarly" | "UpgradeRequired" | "PreconditionRequired" | "TooManyRequests" | "RequestHeaderFieldsTooLarge" | "UnavailableForLegalReasons" | "NotImplemented" | "BadGateway" | "ServiceUnavailable" | "GatewayTimeout" | "HttpVersionNotSupported" | "VariantAlsoNegotiates" | "InsufficientStorage" | "LoopDetected" | "NotExtended" | "NetworkAuthenticationRequired">(literal: L): { readonly Accepted: 202; readonly AlreadyReported: 208; readonly BadGateway: 502; readonly BadRequest: 400; readonly Conflict: 409; readonly Continue: 100; readonly Created: 201; readonly EarlyHints: 103; readonly ExpectationFailed: 417; readonly FailedDependency: 424; readonly Forbidden: 403; readonly Found: 302; readonly GatewayTimeout: 504; readonly Gone: 410; readonly HttpVersionNotSupported: 505; readonly ImATeapot: 418; readonly ImUsed: 226; readonly InsufficientStorage: 507; readonly InternalServerError: 500; readonly LengthRequired: 411; readonly Locked: 423; readonly LoopDetected: 508; readonly MethodNotAllowed: 405; readonly MisdirectedRequest: 421; readonly MovedPermanently: 301; readonly MultipleChoices: 300; readonly MultiStatus: 207; readonly NetworkAuthenticationRequired: 511; readonly NoContent: 204; readonly NonAuthoritativeInformation: 203; readonly NotAcceptable: 406; readonly NotExtended: 510; readonly NotFound: 404; readonly NotImplemented: 501; readonly NotModified: 304; readonly Ok: 200; readonly OK: 200; readonly PartialContent: 206; readonly PayloadTooLarge: 413; readonly PaymentRequired: 402; readonly PermanentRedirect: 308; readonly PreconditionFailed: 412; readonly PreconditionRequired: 428; readonly Processing: 102; readonly ProxyAuthenticationRequired: 407; readonly RangeNotSatisfiable: 416; readonly RequestHeaderFieldsTooLarge: 431; readonly RequestTimeout: 408; readonly ResetContent: 205; readonly SeeOther: 303; readonly ServiceUnavailable: 503; readonly SwitchingProtocols: 101; readonly TemporaryRedirect: 307; readonly TooEarly: 425; readonly TooManyRequests: 429; readonly Unauthorized: 401; readonly UnavailableForLegalReasons: 451; readonly UnprocessableEntity: 422; readonly UnsupportedMediaType: 415; readonly UpgradeRequired: 426; readonly UriTooLong: 414; readonly VariantAlsoNegotiates: 506;}[L]Example
(Obtaining status codes from literal names)
import { HttpStatus } from "effect/unstable/http"
HttpStatus.fromLiteral("OK") // => 200HttpStatus.fromLiteral("Conflict") // => 409