github finagle/finch 0.11.0-M4
Finch 0.11-M4

latest releases: v0.34.1, v0.34.0, v0.33.0...
7 years ago
  • Endpoints testing now easier with polymorphic withBody (see #646)
  • Simplifying the behavior around empty entries (see #642)
  • Better error messages in finch-circe (see #648)

Polymorphic Input.withBody

It's now possible to utilize content-types (type-level strings) in Input.withBody such that a proper encoder (i.e., io.finch.Encode) is picked for the arbitrary value.

Before:

Input.post("/").withBody(Buf.Utf8("text"), Some("text/plain;charset=utf8"))
Input.post("/").withJson(Map("a" -> "b"), Some(Charsets.Utf8))

Now:

// Now:
Input.post("/").withBody[Text.Plain]("text", Some(Charsets.Utf8))
Input.post("/").withBody[Application.Json](Map("a" -> "b"), Some(Charsets.Utf8))

// We get the following for free:
import cats.instances.int._
Input.post("/").withBody[Text.Plain](42)

Empty strings are now treated as Some(""), not None

For the sake of principle of least astonishment, we decided to simplify Finch's core endpoints such as header, param, and body so they resolve into Some("") if the given entity is represented as an empty string (None before). This makes these endpoints both more flexible and less powerful (and actually more lightweight).

Don't miss a new finch release

NewReleases is sending notifications on new releases.