2015-02-05 57 views
0

有没有办法修改整个{}块内的http状态码?我定义编组器与scalaz.concurrent.Task工作,像这样:我可以在完成块中修改http响应状态吗?

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 {...} }

我希望能够修改HTTP状态码repsonse根据任务的结果。

+1

为什么不能你把这种行为到任务编组本身? – jrudolph 2015-02-05 20:47:22

回答

0

的关键是是使用ToResponseMarshallerscalaz.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))) }

相关问题