Finch 0.11-M3
Endpoint[Response]
is now a first class citizen (see #624)- The behavior for
params
endpoint is changed a bit to make it easier to reason about (see #625) - There is new API for testing endpoints (see #619)
- Cats updated to 0.7.0
Downgrading Endpoints
This release makes it easier to work with raw Finagle Response
s in the context of Finch Endpoint
s such that they can be used instead of Output
s.
This now works (no need to wrap with Output
):
val foo: Endpoint[Response] = get(/) { Response(Status.Ok) }
Finagle Response
s play an essential role in Finch's applications when it's much easier to take a shortcut and deal with HTTP types directly. This is why their support should be vital. For example, until 0.11 is here, dealing with raw Response
s is the only way to serve multiple content types within a single service.
Endpoints Testing
This release makes it easier to test Endpoint
s by proving a lightweight API for Input
and exposing some useful methods on Output
.
Here is an example of how Input.post
and Output.value
might be used to write simple tests similar to how functions are tested:
scala> val sum: Endpoint[Int] = post(int :: int) { (a: Int, b: Int) => Ok(a + b) }
sum: io.finch.Endpoint[Int] = POST /:int/:int
scala> sum(Input.post("/10/20")).value == Some(30)
res1: Boolean = true
scala> sum(Input.get("/foo/bar")).value == None
res2: Boolean = true