MCPcopy Create free account
hub / github.com/Effect-TS/effect / withHandler

Function withHandler

packages/platform/deno/test/DenoHttpCompression.test.ts:25–40  ·  view source on GitHub ↗
(
  app: App,
  options: CompressionOptions,
  run: (handler: (request: Request) => Promise<Response>) => Promise<void>
)

Source from the content-addressed store, hash-verified

23type CompressionOptions = Parameters<typeof HttpMiddleware.compression>[0]
24
25const withHandler = async (
26 app: App,
27 options: CompressionOptions,
28 run: (handler: (request: Request) => Promise<Response>) => Promise<void>
29) => {
30 const { dispose, handler } = HttpEffect.toWebHandlerLayer(
31 app as Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest>,
32 DenoHttpPlatform.layer,
33 { middleware: HttpMiddleware.compression(options) }
34 )
35 try {
36 await run(handler)
37 } finally {
38 await dispose()
39 }
40}
41
42const get = (
43 handler: (request: Request) => Promise<Response>,

Callers 1

Calls 2

runFunction · 0.50
disposeFunction · 0.50

Tested by

no test coverage detected