Andrew O'Hara
01/05/2024, 4:00 PMI think that's probably about as clean as you can get it barring some tweakingYeah, that's what I suspected. Thanks for clarifying.
you'd want to just implement a new version ofThat's what I was hoping to avoid 😇 . I don't really understand this class yet, but perhaps I'll have to muscle through it.RoutingHttpHandler
dave
01/05/2024, 4:08 PMdave
01/05/2024, 4:08 PMdave
01/05/2024, 4:14 PMfun List<Int>.buildRoutes() = routes(
map {
{ r: Request -> r.uri.port == it }.asRouter() bind JavaHttpClient()
}
)
fun handler(ports: List<Int>) {
{ req: Request -> ports.buildRoutes()(req) }.asServer(SunHttp(8080)).start()
}
Andrew O'Hara
01/05/2024, 4:15 PMdave
01/05/2024, 4:16 PMfun routes(routers: List<RoutingHttpHandler>): RoutingHttpHandler = routes(*routers.toTypedArray())
dave
01/05/2024, 4:16 PM