Package: @effect/platform
Module: HttpMiddleware
Customizes the span name for the http app.
import {
HttpMiddleware,
HttpRouter,
HttpServer,
HttpServerResponse
} from "@effect/platform"
import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
import { Layer } from "effect"
import { createServer } from "http"
HttpRouter.empty.pipe(
HttpRouter.get("/", HttpServerResponse.empty()),
HttpServer.serve(),
// Customize the span names for this HttpApp
HttpMiddleware.withSpanNameGenerator((request) => `GET ${request.url}`),
Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 })),
Layer.launch,
NodeRuntime.runMain
)
Signature
declare const withSpanNameGenerator: { (f: (request: ServerRequest.HttpServerRequest) => string): <A, E, R>(layer: Layer.Layer<A, E, R>) => Layer.Layer<A, E, R>; <A, E, R>(layer: Layer.Layer<A, E, R>, f: (request: ServerRequest.HttpServerRequest) => string): Layer.Layer<A, E, R>; }
Since v1.0.0