File size: 1,516 Bytes
31e8457 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /**
* @since 4.0.0
*/
/**
* @since 4.0.0
* @category models
*/
export type HttpMethod =
| "GET"
| "POST"
| "PUT"
| "DELETE"
| "PATCH"
| "HEAD"
| "OPTIONS"
| "TRACE"
/**
* @since 4.0.0
* @category models
*/
export declare namespace HttpMethod {
/**
* @since 4.0.0
* @category models
*/
export type NoBody = "GET" | "HEAD" | "OPTIONS" | "TRACE"
/**
* @since 4.0.0
* @category models
*/
export type WithBody = Exclude<HttpMethod, NoBody>
}
/**
* @since 4.0.0
*/
export const hasBody = (method: HttpMethod): method is HttpMethod.WithBody =>
method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE"
/**
* @since 4.0.0
*/
export const all: ReadonlySet<HttpMethod> = new Set([
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"TRACE"
])
/**
* @since 4.0.0
*/
export const allShort = [
["GET", "get"],
["POST", "post"],
["PUT", "put"],
["DELETE", "del"],
["PATCH", "patch"],
["HEAD", "head"],
["OPTIONS", "options"],
["TRACE", "trace"]
] as const
/**
* Tests if a value is a `HttpMethod`.
*
* **Example**
*
* ```ts
* import { HttpMethod } from "effect/unstable/http"
*
* console.log(HttpMethod.isHttpMethod("GET"))
* // true
* console.log(HttpMethod.isHttpMethod("get"))
* // false
* console.log(HttpMethod.isHttpMethod(1))
* // false
* ```
*
* @since 4.0.0
* @category refinements
*/
export const isHttpMethod = (u: unknown): u is HttpMethod => all.has(u as HttpMethod)
|