有很多原因可以解释为什么
HttpRequest
不匹配
Route
在akka中指定。举几个例子:
-
这个
Path
请求的任何路径匹配器都可能不匹配。
-
这个
"Accept Encoding"
请求的头可能与
-
这个
request method
可能是错的。
-
...
更糟糕的是,路由创建者可以以各种方式组合需求。例如,如果路由定义为
val route =
post {
path("only" / "match" / "post" / "request") {
complete("good post request")
}
} ~
get {
path("only" / "match" / "get / "request") {
complete("good get request")
}
}
GET
带着小路
"/only/match/post/request"
诊断信息
服务器创建者有责任提供“诊断”信息:
val route =
get {
complete("good user, only get requests are matched")
} ~
complete(405 -> "bad user, only get requests are matched")
我同意你的说法,即这个问题“有点过分”。这个问题似乎类似于这样一个问题:“为什么akka不为我编写服务器?”