我有以下代码功能:
def jsonOrBadRequest[F[_] : Monad](service: HttpService[F])
: HttpService[F]
= {
object dsl extends Http4sDsl[F]
import dsl._
Kleisli[OptionT[F, ?], Request[F], Response[F]] { req =>
req.contentType match {
case Some(s) =>
if (s != `Content-Type`(MediaType.`application/json`))
OptionT.liftF(BadRequest("Malformed format."))
else
service(req)
case None =>
OptionT.liftF(BadRequest("Malformed format."))
}
}
}
并想知道,问号是什么意思?它来自图书馆https://github.com/non/kind-projector。