()
| 214 | middleware.add(middleware_ as any) |
| 215 | }), |
| 216 | asHttpEffect() { |
| 217 | let handler = Effect.withFiber<HttpServerResponse.HttpServerResponse, unknown>((fiber) => { |
| 218 | let context = fiber.context |
| 219 | const request = Context.getUnsafe(context, HttpServerRequest.HttpServerRequest) |
| 220 | let result = router.find(request.method, request.url) |
| 221 | let paramLimit = result === undefined ? getMaxParamLengthExceeded(router) : undefined |
| 222 | if (result === undefined && request.method === "HEAD") { |
| 223 | result = router.find("GET", request.url) |
| 224 | paramLimit ??= getMaxParamLengthExceeded(router) |
| 225 | } |
| 226 | if (result === undefined) { |
| 227 | return Effect.fail( |
| 228 | new HttpServerError.HttpServerError({ |
| 229 | reason: new HttpServerError.RouteNotFound( |
| 230 | paramLimit === undefined |
| 231 | ? { request } |
| 232 | : { request, description: `path parameter is longer than maxParamLength (${paramLimit})` } |
| 233 | ) |
| 234 | }) |
| 235 | ) |
| 236 | } |
| 237 | const { route, prefixSegments, redactedPath } = result.handler |
| 238 | if (prefixSegments !== undefined) { |
| 239 | context = Context.add( |
| 240 | context, |
| 241 | HttpServerRequest.HttpServerRequest, |
| 242 | sliceRequestUrl(request, prefixSegments, ignoreDuplicateSlashes, segmentEnd) |
| 243 | ) |
| 244 | } |
| 245 | context = Context.add(context, HttpServerRequest.ParsedSearchParams, result.searchParams) |
| 246 | context = Context.add(context, RouteContext, { |
| 247 | route, |
| 248 | params: result.params |
| 249 | }) |
| 250 | |
| 251 | if (redactedPath !== undefined) { |
| 252 | const state = Context.getOrUndefined(context, CurrentRequestState) |
| 253 | if (state !== undefined) { |
| 254 | state.redactedPath = RedactedPath.combine( |
| 255 | state.redactedPath, |
| 256 | RedactedPath.render(redactedPath, result.params), |
| 257 | request |
| 258 | ) |
| 259 | } |
| 260 | } |
| 261 | if (fiber.getRef(Tracer.Tracer) !== Tracer.nativeTracer) { |
| 262 | const span = Context.getOrUndefined(context, Tracer.ParentSpan) |
| 263 | if (span !== undefined && span._tag === "Span" && span.sampled) { |
| 264 | span.attribute("http.route", route.path) |
| 265 | } |
| 266 | } |
| 267 | // The enclosing request restores the fiber context on exit. |
| 268 | fiber.setContext(context) |
| 269 | if (!route.uninterruptible) { |
| 270 | const interrupted = fiberEnterInterruptibleUnsafe(fiber) |
| 271 | if (interrupted !== undefined) return interrupted |
| 272 | } |
| 273 | return route.handler as Effect.Effect< |
nothing calls this directly
no test coverage detected