finagle/finch — pull request #107 by rodrigopr (2014-12-12 23:23:35+00:00)
Title: Implicit converter from Json to HttpResponse

This add support for automatic conversion from `Service[Req, T]` to `Service[Req, HttpResponse]` when an `Encoder[T]` is provided, such as:

```scala
trait Json

implicit val encode = new EncodeJson[Json] { def apply(j: Json) = "42" }

val service: Service[HttpRequest, Json] = ???

val e = Endpoint[HttpRequest, HttpResponse] {
case Method.Get -> Root / "a" => service // should be implicitly converted into http
}
```

When type information is not provided to compiler, you can still force the conversion using the `.asJson` method:
```scala
val e = Endpoint {
case Method.Get -> Root / "a" => service.asJson
}
```

Futures are also supported:
```scala

val e = Endpoint[HttpRequest, HttpResponse] {
case Method.Get -> Root / "a" => (new Json).toFuture
}
```
Likewise, we can also for conversion of the future with the `.asJson`

Addresses #104