Effect CommunityEC
Effect Community10mo ago
3 replies
wayne

Applying Middleware to Specific Endpoint Handlers in Effect-TS HTTP API

The documentation for HTTP API it says that we can define an endpoint with a middleware:
https://github.com/Effect-TS/effect/tree/main/packages/platform#implementing-httpapimiddleware
e.g. HttpApiEndpoint.get("get", "/").addSuccess(Schema.String).middleware(Authorization)
We can than apply the implemented middleware when implementing the group:
e.g. HttpApiBuilder.group( ... ).pipe(Layer.provide(AuthorizationLive))
However I don't want to apply the middleware to the group, only to the specific handler as specified in the definition of the endpoint.
Is there a way to provide a middleware implementation to handlers.handle ?
Was this page helpful?