MCPcopy Create free account
hub / github.com/effect-app/libs / HttpClientLayer

Function HttpClientLayer

packages/effect-app/src/client/apiClientFactory.ts:57–78  ·  view source on GitHub ↗
(config: ApiConfig)

Source from the content-addressed store, hash-verified

55}) {}
56
57export const HttpClientLayer = (config: ApiConfig) =>
58 Layer.effect(
59 HttpClient.HttpClient,
60 Effect
61 .gen(function*() {
62 const baseClient = yield* HttpClient.HttpClient
63 const client = baseClient.pipe(
64 HttpClient.mapRequest(HttpClientRequest.prependUrl(config.url + "/rpc")),
65 HttpClient.mapRequest(
66 HttpClientRequest.setHeaders(config.headers.pipe(Option.getOrElse(() => ({}))))
67 ),
68 HttpClient.mapRequestEffect((req) =>
69 Effect.map(RequestName, (ctx) =>
70 flow(
71 HttpClientRequest.appendUrlParam("action", ctx.requestName),
72 HttpClientRequest.appendUrl("/" + ctx.moduleName)
73 )(req))
74 )
75 )
76 return client
77 })
78 )
79
80export const HttpClientFromConfigLayer = Layer.unwrap(
81 Effect.gen(function*() {

Callers 2

RpcSerializationLayerFunction · 0.85

Calls 2

pipeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…