我有一条类似于在HTTP4K工作良好的下面的路线。但是,必须重复对"/“绑定的调用是很烦人的。我一直在寻找一种更简单的方式来表达DSL,但是其他的似乎都没有用。有办法做到这一点吗?
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()发布于 2019-06-13 16:56:52
有一个同名的方便函数,它接受Pair<Method, HttpHandler>的vararg,您应该能够按如下方式删除领先的"/" bind:
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()https://stackoverflow.com/questions/56583232
复制相似问题