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

Function request

packages/platform/test/HttpLayerRouter.test.ts:84–98  ·  view source on GitHub ↗
(
      app: Layer.Layer<never, never, HttpLayerRouter.HttpRouter>,
      init?: RequestInit,
      path = "/admin/stats"
    )

Source from the content-addressed store, hash-verified

82 const Admin = HttpLayerRouter.add("GET", "/admin/stats", HttpServerResponse.text("admin stats"))
83
84 const request = async (
85 app: Layer.Layer<never, never, HttpLayerRouter.HttpRouter>,
86 init?: RequestInit,
87 path = "/admin/stats"
88 ) => {
89 const { dispose, handler } = HttpLayerRouter.toWebHandler(app.pipe(Layer.provide(HttpServer.layerContext)), {
90 disableLogger: true
91 })
92 try {
93 const response = await handler(new Request(`http://localhost${path}`, init))
94 return { status: response.status, body: await response.text() }
95 } finally {
96 await dispose()
97 }
98 }
99
100 test("only serves sub-app routes through the mount", async () => {
101 const app = HttpLayerRouter.use(Effect.fnUntraced(function*(router) {

Callers 1

Calls 5

pipeMethod · 0.65
provideMethod · 0.65
handlerFunction · 0.50
disposeFunction · 0.50
textMethod · 0.45

Tested by

no test coverage detected