Skip to content

Finch 0.16-M6

Compare
Choose a tag to compare
@vkostyukov vkostyukov released this 22 Dec 19:09
· 899 commits to master since this release
78720cd

(Hopefully) the last milestone release for 0.16 (which will be released in against Cats 1.0 once it's available):

  • Cats 1.0-RC2 and Circe 0.9-M3
  • Finagle/Util 17.12

Multiple file-uploads & attributes

This milestone release accompanied by a new set of endpoints to read multiple file-uploads (thanks @jguitana, see #811) and multipart attributes (see #872).

import io.finch._

scala> val foo = multipartAttributesNel("foo") 
foo: io.finch.Endpoint[cats.data.NonEmptyList[String]] = attributes(foo)

scala> val bar = multipartFileUploadsNel("bar")
bar: io.finch.Endpoint[cats.data.NonEmptyList[com.twitter.finagle.http.exp.Multipart.FileUpload]] = bar

Deprecating .as[Foo] syntax

We're deprecating an old style type-converters available via the .as[A] syntax extension (thanks @imliar, see #875). Instead, we're offering a new API that accepts a target type at the moment endpoint is created. This is supported by param(s), header, and multipartAttribute(s) endpoints.

scala> val p = param("p").as[Int]
<console>:38: warning: method as in class StringEndpointOps is deprecated (since 0.16)
       val p = param("p").as[Int]
                          ^
p: io.finch.Endpoint[Int] = param(p)

scala> val q = param[Int]("q")
q: io.finch.Endpoint[Int] = param(q)

The new API isn't just easier to write/read but also more efficient as it allows to skip an interim endpoint creation (needed to accommodate the as operation).

Note:

  • param("foo") (no type-parameter) is still supported and defaults to param[String]("foo").
  • Endpoint[L <: HList] -> Endpoint[Foo] conversion is still supported via the standart means of as[Foo] operation.

Deprecating implicit Sinatra-like syntax

After 0.16, Finch's Sinatra-like syntax should be explicitly imported (see #876).

scala> import io.finch._
import io.finch._

scala> val p = get(/) { Ok("foo") }
val p = get(/) { Ok("foo") }
<console>:14: warning: method get in trait DeprecatedEndpointMappers is deprecated (since 0.16): Enable syntax explicitly: import io.finch.syntax._
       val p = get(/) { Ok("foo") }
               ^
p: io.finch.Endpoint[String] = GET /

scala> import io.finch.syntax._
import io.finch.syntax._

scala> val p = get(/) { Ok("foo") }
val p = get(/) { Ok("foo") }
p: io.finch.Endpoint[String] = GET /