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

Function handler

repos/effect/packages/effect/src/unstable/http/HttpEffect.ts:320–337  ·  view source on GitHub ↗
(
    request: Request,
    context?: Context.Context<ReqR> | undefined
  )

Source from the content-addressed store, hash-verified

318 let handlerPromise:
319 | Promise<(request: Request, context?: Context.Context<ReqR> | undefined) => Promise<globalThis.Response>>
320 | undefined
321 function handler(
322 request: Request,
323 context?: Context.Context<ReqR> | undefined
324 ): Promise<globalThis.Response> {
325 if (handlerCache) {
326 return handlerCache(request, context)
327 }
328 handlerPromise ??= Effect.runPromise(Effect.gen(function*() {
329 const context = yield* (options.memoMap
330 ? Layer.buildWithMemoMap(layer, options.memoMap, scope)
331 : Layer.buildWithScope(layer, scope))
332 return handlerCache = toWebHandlerWith<Provided, R>(context)(
333 yield* options.toHandler(context),
334 options.middleware
335 ) as any
336 }))
337 return handlerPromise.then((f) => f(request, context))
338 }
339 return { dispose, handler: handler as any } as const
340}

Callers 5

handleCauseFunction · 0.70
toHandledFunction · 0.70
fromWebHandlerFunction · 0.70
handlerToHttpEffectFunction · 0.50

Calls 2

toWebHandlerWithFunction · 0.85
fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…