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

Function route

packages/effect/src/unstable/http/HttpRouter.ts:669–690  ·  view source on GitHub ↗
(
  method: "*" | HttpMethod.HttpMethod,
  path: PathInput,
  handler:
    | HttpServerResponse.HttpServerResponse
    | Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
    | ((request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>),
  options?: {
    readonly uninterruptible?: boolean | undefined
  }
)

Source from the content-addressed store, hash-verified

667 * @since 4.0.0
668 */
669export const route = <E = never, R = never>(
670 method: "*" | HttpMethod.HttpMethod,
671 path: PathInput,
672 handler:
673 | HttpServerResponse.HttpServerResponse
674 | Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>
675 | ((request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>),
676 options?: {
677 readonly uninterruptible?: boolean | undefined
678 }
679): Route<E, Exclude<R, Provided>> =>
680 makeRoute({
681 ...options,
682 method,
683 path,
684 handler: HttpServerResponse.isHttpServerResponse(handler) ?
685 Effect.succeed(handler) :
686 Effect.isEffect(handler)
687 ? handler
688 : Effect.flatMap(HttpServerRequest.HttpServerRequest, handler),
689 uninterruptible: options?.uninterruptible ?? false
690 })
691
692/**
693 * Path pattern accepted by the router. Routes must use an absolute path

Callers 1

HttpRouter.tsFile · 0.85

Calls 2

makeRouteFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected