我已经定义了以下路线:
object InterestRoutes {
def apply[F[_]: Sync](query: InterestProgram[F]): InterestRoutes[F] = new InterestRoutes[F](query)
}
final class InterestRoutes[F[_]: Sync](query: InterestProgram[F]) extends Http4sDsl[F] {
private val path = "/interests"
private val httpRoutes: HttpRoutes[F] = HttpRoutes.of[F] {
case GET -> Root =>
Ok(query.findAll.map(i => i.asJson))
}
def routes: HttpRoutes[F] = Router(
path -> InterestHttpErrorHandler[F].handle(httpRoutes)
)
}
我试图撰写到父路径:
private def routes[F[_]: Sync: Timer](xa: Transactor[F]): HttpApp[F] =
Router("/api" -> InterestRoutes(InterestProgram(LiveInterestQuery.make(xa))).routes).orNotFound
当我调用 URLhttp://localhost:8080/api/interests
时,我得到了Not found
.
我究竟做错了什么?