Exploring Staggered Construction for API Request Handlers

I've had a thought regarding request handlers. would it be possible to provide an api for staggered construction of the handlers themselves?
This ofc can be done by using services that are the handlers and constructing them first ofc, but it feels patchy a bit
declare const GetFoo: Effect<ServerResponse, never, Foos>
declare const GetBar: Effect<Effect<ServerResponse>, never, Bars>>

export const router = Http.router.empty.pipe(
  Http.router.get("/foos/:id", GetFoo),
  Http.router.getEffect("/bars/:id", GetBar),
);

A different approach would be to allow to construct routes and routers in (or as) a
Layer
.
This would allow ergonomics for both users who prefer the "JIT" approach utilising Effect.Tag (current)
and those who prefer a "precompilation" or "layered" approach
Was this page helpful?