github finagle/finch 0.24.0
Finch 0.24

latest releases: v0.34.1, v0.34.0, v0.33.0...
6 years ago

This is matching release for Finagle 18.9 (September 2018). Additional this bring a couple of improvements and fixes.

Support to 415 UnsupportedMediaType

It's now possible to configure Bootstrap to respond 415 UnsupportedMediaType from a derived service should the incoming request has a wrong media type. The default behavior kept unchanged and 400 BadRequest is returned. See #980 for more details.

As a side bonus this changes the way we apply decoders to HTTP payloads. Starting this release a decoder won't be applied until its content-type matches requests' (it fails-fast when not matched).

scala> case class Foo(s: String)
defined class Foo

scala> val b = jsonBody[Foo]
b: io.finch.Endpoint[Foo] = body

scala> val s = Bootstrap
  .configure(enableUnsupportedMediaType = true)
  .serve[Application.Json](b)
  .toService

s: com.twitter.finagle.Service[com.twitter.finagle.http.Request,com.twitter.finagle.http.Response] = io.finch.ToService$$anon$4$$anon$2

scala> Http.server.serve(:8081, s)

And then:

$ http :8081 s=bar
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 18 Sep 2018 03:29:58 GMT
Server: Finch
content-encoding: gzip
content-length: 37

{
    "s": "bar"
}

$ http :8081 Content-Type:text/plain s=bar
HTTP/1.1 415 Unsupported Media Type
Content-Length: 0
Date: Tue, 18 Sep 2018 03:30:24 GMT
Server: Finch

Finch with Arrows

We're still publishing Finch artifacts with Trane Arrows as they seem to provide a better throughput. This is, however, going to be our last release with Trane Arrows. The current plan for 0.25 is make Endpoint polymorphic in terms of its effect type (see #979).

Other Changes

Don't miss a new finch release

NewReleases is sending notifications on new releases.