MCPcopy
hub / github.com/Effect-TS/effect / handler

Function handler

packages/platform/src/HttpApp.ts:281–298  ·  view source on GitHub ↗
(request: Request, context?: Context.Context<never> | undefined)

Source from the content-addressed store, hash-verified

279 | Promise<(request: Request, context?: Context.Context<never> | undefined) => Promise<Response>>
280 | undefined
281 function handler(request: Request, context?: Context.Context<never> | undefined): Promise<Response> {
282 if (handlerCache) {
283 return handlerCache(request, context)
284 }
285 handlerPromise ??= Effect.gen(function*() {
286 const runtime = yield* (options.memoMap
287 ? Layer.toRuntimeWithMemoMap(layer, options.memoMap)
288 : Layer.toRuntime(layer))
289 return handlerCache = toWebHandlerRuntime(runtime)(
290 yield* options.toHandler(runtime),
291 options.middleware
292 )
293 }).pipe(
294 Scope.extend(scope),
295 Effect.runPromise
296 )
297 return handlerPromise.then((f) => f(request, context))
298 }
299 return { dispose, handler } as const
300}
301

Callers 8

onMessageFunction · 0.70
runFunction · 0.70
runRawFunction · 0.70
fromWebHandlerFunction · 0.70
HttpApp.test.tsFile · 0.50
appendPreResponseHandlerFunction · 0.50
httpApp.tsFile · 0.50
emitFunction · 0.50

Calls 3

toWebHandlerRuntimeFunction · 0.85
pipeMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…