Is there a way to join 2 http handlers together? i...
# http4k
t
Is there a way to join 2 http handlers together? i.e if the path isn't covered by the first http handler, fallback to the second?
d
that's entirely what routing is for...
you can selectively match on anything in the request
t
So I have two http handlers that already have their own routing. I have a first http handler which has a few routes that all our applications use. And a second http handler with routes for a specific application. I guess I probably want the first http handler to instead be a Filter?
d
no - you can compose 2 routes blocks together
t
Ok thanks. I think the spanner in the works is that we're using krouton for that first http handler, and I'm not sure how to get our application specific RoutedHttpHandler to play nicely with what that spits out. I'll take another look at the docs
d
Copy code
val a = routes(
    routes("/foo" bind Method.GET to { Response(OK).body("hellofoo") }),
    routes("/bar" bind Method.GET to { Response(OK).body("hellobar") }),
)
👍 1
I'm not sure how krouton works in terms of exposing a RoutingHttpHandler
s
From memory, krouton turns routing logic into a single HttpHandler.
d
You could fallback on anothr handler using a custom filter - this should be trivial to write