github finagle/finch 0.11.0-M3
Finch 0.11-M3

latest releases: v0.34.1, v0.34.0, v0.33.0...
7 years ago
  • 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 Responses in the context of Finch Endpoints such that they can be used instead of Outputs.

This now works (no need to wrap with Output):

val foo: Endpoint[Response] = get(/) { Response(Status.Ok) }

Finagle Responses 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 Responses is the only way to serve multiple content types within a single service.

Endpoints Testing

This release makes it easier to test Endpoints 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

Don't miss a new finch release

NewReleases is sending notifications on new releases.