我正在Akka-Http中编写一条简单的路由,以了解路由机制。我的路线文件是
val newsApiRoutes = get {
pathSingleSlash {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<html><body>Simple Get Request</body></html>"))
} ~
path("ping") {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<html><body>Playing Ping Pong</body></html>"))
}
}
当我碰到端点http://localhost:8080/ping
时,得到的输出Playing Ping Pong
在预期的行上。但是现在,当我添加一条路线
val newsApiRoutes = get {
pathSingleSlash {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<html><body>Simple Get Request</body></html>"))
} ~
path("ping") {
pathSingleSlash{
path("pong"){
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<html><body>Playing Ping Pong</body></html>"))
}
}
}
}
,我用http://localhost:8080/ping/pong
击中了端点,我得到404错误,引用The requested resource could not be found.
,有人可以让我知道我要去哪里了。在此先感谢!!!