我正在尝试为特定路径创建发布端点,但收到错误消息
模式类型与找到的预期类型ContextRequest[F,A]不兼容,需要:请求[F]
case _ @ POST -> Root / "batch-notify" as _ =>
handler.handle("create.notifications.batchNotify") {
for {
_ <- log.info("Running batch notification job") *> Sync[F].pure(())
r <- batchingService.createNotifications.flatMap(_ => Ok())
} yield r
}.fireAndForget.flatMap(_ => Accepted())
我对Scala还是个新手,我尝试过修复它,但毫无进展,有人能帮忙吗?
1条答案
按热度按时间enxuqcxy1#
akka
akka
是用于
AuthedRoutes
的AuthedRequest
https://http4s.org/v1/docs/auth.html
如果您将其放入模式匹配中,其中
Request
预期为HttpRoutes
(即没有身份验证)https://http4s.org/v1/docs/service.html
就会出现编译错误
您可以在www.example.com上找到如何将
AuthedRoutes
与HttpRoutes
组合的示例https://http4s.org/v1/docs/auth.html#composing-authenticated-routes