在Akka Http中添加路由时出现404错误

时间:2018-10-16 06:05:34

标签: scala akka-http

我正在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.,有人可以让我知道我要去哪里了。在此先感谢!!!

0 个答案:

没有答案