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

Function sendResponse

packages/effect/src/http/HttpEffect.ts:91–113  ·  view source on GitHub ↗
(
    frame: RequestFrame,
    response: HttpServerResponse
  )

Source from the content-addressed store, hash-verified

89 }
90
91 const sendResponse = (
92 frame: RequestFrame,
93 response: HttpServerResponse
94 ): Effect.Effect<HttpServerResponse, EH | HttpServerError, RH> => {
95 const request = frame.request
96 const handler = frame.preResponseHandler
97 if (handler === undefined) {
98 ;(request as any)[handledSymbol] = true
99 return Effect.mapEager(
100 handleResponse(request, response),
101 (sent) => Response.isHttpServerResponse(sent) ? sent : response
102 )
103 }
104 // Clear before calling the hook so recovery cannot run it again, even if it throws.
105 frame.preResponseHandler = undefined
106 return Effect.flatMapEager(handler(request, response), (sentResponse) => {
107 ;(request as any)[handledSymbol] = true
108 return Effect.mapEager(
109 handleResponse(request, sentResponse),
110 (sent) => Response.isHttpServerResponse(sent) ? sent : response
111 )
112 })
113 }
114
115 const withMiddleware = (frame: RequestFrame): Effect.Effect<
116 unknown,

Callers 3

withMiddlewareFunction · 0.85
sendUnhandledFunction · 0.85
[contA]Method · 0.85

Calls 2

handlerFunction · 0.70
handleResponseFunction · 0.50

Tested by

no test coverage detected