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

Function toWebHandler

packages/rpc/src/RpcServer.ts:1310–1340  ·  view source on GitHub ↗
(
  group: RpcGroup.RpcGroup<Rpcs>,
  options: {
    readonly layer: Layer.Layer<
      | Rpc.ToHandler<Rpcs>
      | Rpc.Middleware<Rpcs>
      | RpcSerialization.RpcSerialization
      | HttpRouter.HttpRouter.DefaultServices,
      LE
    >
    readonly disableTracing?: boolean | undefined
    readonly spanPrefix?: string | undefined
    readonly spanAttributes?: Record<string, unknown> | undefined
    readonly disableFatalDefects?: boolean | undefined
    readonly middleware?: (
      httpApp: HttpApp.Default
    ) => HttpApp.Default<
      never,
      HttpRouter.HttpRouter.DefaultServices
    >
    readonly memoMap?: Layer.MemoMap
  }
)

Source from the content-addressed store, hash-verified

1308 * @category constructors
1309 */
1310export const toWebHandler = <Rpcs extends Rpc.Any, LE>(
1311 group: RpcGroup.RpcGroup<Rpcs>,
1312 options: {
1313 readonly layer: Layer.Layer<
1314 | Rpc.ToHandler<Rpcs>
1315 | Rpc.Middleware<Rpcs>
1316 | RpcSerialization.RpcSerialization
1317 | HttpRouter.HttpRouter.DefaultServices,
1318 LE
1319 >
1320 readonly disableTracing?: boolean | undefined
1321 readonly spanPrefix?: string | undefined
1322 readonly spanAttributes?: Record<string, unknown> | undefined
1323 readonly disableFatalDefects?: boolean | undefined
1324 readonly middleware?: (
1325 httpApp: HttpApp.Default
1326 ) => HttpApp.Default<
1327 never,
1328 HttpRouter.HttpRouter.DefaultServices
1329 >
1330 readonly memoMap?: Layer.MemoMap
1331 }
1332): {
1333 readonly handler: (request: globalThis.Request, context?: Context.Context<never> | undefined) => Promise<Response>
1334 readonly dispose: () => Promise<void>
1335} =>
1336 HttpApp.toWebHandlerLayerWith(Layer.mergeAll(options.layer, Layer.scope), {
1337 memoMap: options?.memoMap,
1338 middleware: options?.middleware as any,
1339 toHandler: (r) => Effect.provide(toHttpApp(group, options), r)
1340 })
1341
1342/**
1343 * Create a protocol that uses the provided `Stream` and `Sink` for communication.

Callers

nothing calls this directly

Calls 2

toHttpAppFunction · 0.85
provideMethod · 0.65

Tested by

no test coverage detected