HTTP request method and URL matching
import * as Http from "@effect/platform-bun/HttpClient";
declare const method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
declare const url: string;
const req = Match.value(method)
.pipe(
Match.when("GET", () => Http.request.get),
Match.when("POST", () => Http.request.post),
Match.when("PUT", () => Http.request.put),
Match.when("PATCH", () => Http.request.patch),
Match.when("DELETE", () => Http.request.del),
Match.exhaustive
)(url)import * as Http from "@effect/platform-bun/HttpClient";
declare const method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
declare const url: string;
const req = Match.value(method)
.pipe(
Match.when("GET", () => Http.request.get),
Match.when("POST", () => Http.request.post),
Match.when("PUT", () => Http.request.put),
Match.when("PATCH", () => Http.request.patch),
Match.when("DELETE", () => Http.request.del),
Match.exhaustive
)(url)While this works fine, is there a better way to accomplish this
the current non-overlapping overload signature of
Http.request.makeHttp.request.make declare const make: {
(method: "GET" | "HEAD"): (url: string, options?: Options.NoBody) => ClientRequest
(
method: Exclude<Method, "GET" | "HEAD">
): (url: string, options?: Options.NoUrl) => ClientRequest
}declare const make: {
(method: "GET" | "HEAD"): (url: string, options?: Options.NoBody) => ClientRequest
(
method: Exclude<Method, "GET" | "HEAD">
): (url: string, options?: Options.NoUrl) => ClientRequest
}means you cant just do
Http.request.make(method)(url)Http.request.make(method)(url)