Skip to content

HttpMethod.ts

Union of supported uppercase HTTP method literals.

Since v4.0.0



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>

Source

Since v4.0.0

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"]
]

Source

Since v4.0.0

Union of supported uppercase HTTP method literals.

Signature

type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE"

Source

Since v4.0.0

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.WithBody

Source

Since v4.0.0

Checks whether a value is a HttpMethod.

Example (Checking HTTP method values)

import { HttpMethod } from "effect/unstable/http"
console.log(HttpMethod.isHttpMethod("GET"))
// true
console.log(HttpMethod.isHttpMethod("get"))
// false
console.log(HttpMethod.isHttpMethod(1))
// false

Signature

declare const isHttpMethod: (u: unknown) => u is HttpMethod

Source

Since v4.0.0

Namespace containing subtype helpers associated with HttpMethod.

Source

Since v4.0.0

HTTP methods that this module treats as not carrying a request body.

Signature

type NoBody = "GET" | "HEAD" | "OPTIONS" | "TRACE"

Source

Since v4.0.0

HTTP methods that this module treats as capable of carrying a request body.

Signature

type WithBody = Exclude<HttpMethod, NoBody>

Source

Since v4.0.0