有没有办法修改完整{}块内的http状态代码?我已经定义了一个Marshaller与scalaz.concurrent.Task
一起工作:
implicit def taskMarshaller[A](implicit m: Marshaller[A]) =
Marshaller[scalaz.concurrent.Task[A]]{(task, ctx) =>
task.runAsync(_.fold(l => throw l, r => m(r, ctx)))
}
我做了
complete {
Task {...}
}
我希望能够根据任务的结果修改repsonse中的http状态代码。
答案 0 :(得分:0)
关键是对ToResponseMarshaller
使用scalaz.concurrent.Task[(StatusCode, A)]
,如下所示:
implicit def scalazTaskWithStatusMarshaller[A](implicit m: ToResponseMarshaller[(StatusCode, A)]): ToResponseMarshaller[scalaz.concurrent.Task[(StatusCode, A)]] =
ToResponseMarshaller[scalaz.concurrent.Task[(StatusCode, A)]] { (task, ctx) =>
task.runAsync(_.fold(l => throw l, r => m(r, ctx)))
}