我用http4s定义了这个简单的路由:
def routes: HttpRoutes[UserTask] =
HttpRoutes.of[UserTask] {
case GET -> Root / IntVar(id) =>
... // returns a specific user
case GET -> Root => // this line gives the warning
Persistence.>.all().foldM( ... // returns all users
case request@POST -> Root =>
....
}
路线按预期工作。
有没有办法避免这个警告?
这是堆栈跟踪:
[info] Compiling 21 Scala sources to /Users/mpa/dev/Github/pme123/zio-examples/out/entity/compile/dest/classes ...
[warn] /Users/mpa/dev/Github/pme123/zio-examples/entity/src/pme123/zio/examples/api/Api.scala:24:34: unreachable code
[warn] Persistence.>.all().foldM(_ => NotFound(), Ok(_))
[warn] ^
[warn] one warning found
[info] Done compiling.