I have a route similar to the one below working fine in HTTP4K. However it is annoying having to repeat the calls to "/" bind. I have looked for a simpler way to express the DSL but nothing else seems to work. Is there any way to achieve this?
routes(
"/things" bind routes(
"/" bind Method.GET to allThings,
"/{id:.*}" bind routes (
"/" bind Method.GET to singleThing,
"/" bind Method.DELETE to deleteThing,
"/" bind Method.PUT to addOrUpdateThing
)
)
).asServer(Netty(8080))
.start()
There is a convenience function of the same name which accepts a vararg of Pair<Method, HttpHandler>
, you should be able to drop the leading "/" bind
as follows:
routes(
"/things" bind routes(
"/" bind Method.GET to allThings,
"/{id:.*}" bind routes(
Method.GET to singleThing,
Method.DELETE to deleteThing,
Method.PUT to addOrUpdateThing
)
)
).asServer(Netty(8080))
.start()