HttpMethod.ts
HttpMethod.ts overview
Section titled “HttpMethod.ts overview”Union of supported uppercase HTTP method literals.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”constants
Section titled “constants”Provides a readonly set containing every supported HttpMethod literal.
When to use
Use when you need to iterate over or test membership against every supported HTTP method literal.
Signature
declare const all: ReadonlySet<HttpMethod>Since v4.0.0
allShort
Section titled “allShort”Provides tuples mapping each supported HTTP method to its short request-constructor name.
When to use
Use when you need the mapping from supported HTTP method literals to their short request-constructor names.
Signature
declare const allShort: readonly [ readonly ["GET", "get"], readonly ["POST", "post"], readonly ["PUT", "put"], readonly ["DELETE", "del"], readonly ["PATCH", "patch"], readonly ["HEAD", "head"], readonly ["OPTIONS", "options"], readonly ["TRACE", "trace"]]Since v4.0.0
models
Section titled “models”HttpMethod (type alias)
Section titled “HttpMethod (type alias)”Union of supported uppercase HTTP method literals.
Signature
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE"Since v4.0.0
predicates
Section titled “predicates”hasBody
Section titled “hasBody”Returns true when a method can carry a request body and narrows it to HttpMethod.WithBody.
Signature
declare const hasBody: (method: HttpMethod) => method is HttpMethod.WithBodySince v4.0.0
refinements
Section titled “refinements”isHttpMethod
Section titled “isHttpMethod”Checks whether a value is a HttpMethod.
Example (Checking HTTP method values)
import { HttpMethod } from "effect/unstable/http"
console.log(HttpMethod.isHttpMethod("GET"))// trueconsole.log(HttpMethod.isHttpMethod("get"))// falseconsole.log(HttpMethod.isHttpMethod(1))// falseSignature
declare const isHttpMethod: (u: unknown) => u is HttpMethodSince v4.0.0
HttpMethod (namespace)
Section titled “HttpMethod (namespace)”Namespace containing subtype helpers associated with HttpMethod.
Since v4.0.0
NoBody (type alias)
Section titled “NoBody (type alias)”HTTP methods that this module treats as not carrying a request body.
Signature
type NoBody = "GET" | "HEAD" | "OPTIONS" | "TRACE"Since v4.0.0
WithBody (type alias)
Section titled “WithBody (type alias)”HTTP methods that this module treats as capable of carrying a request body.
Signature
type WithBody = Exclude<HttpMethod, NoBody>Since v4.0.0