【发布时间】:2018-09-24 08:20:57
【问题描述】:
我正在尝试编写一系列简单的路线,这就是我想要发生的事情:
GET / 应该打印“hello get”
POST / 应该打印“hello post”
GET /foo 应该打印“hello foo get”
POST /foo 应该打印“hello foo get”
这是我所拥有的:
val route = pathSingleSlash {
get(complete("hello get")) ~
post(complete("hello post"))~
path("foo") {
get(complete("hello foo get"))~
post(complete("hello foo post"))
}
}
这适用于GET / 和POST /,但在/foo 404 上进行GET 和POST。
我几乎尝试了所有方法,但不知道该怎么做。当涉及到这一点时,文档很难理解。
谁能指点一下?
【问题讨论】:
-
path 匹配值到傻瓜路径,尝试使用 pathPrefix 代替 path