Skip to content

Releases: sparsetech/trail

v0.3.1

25 Jan 10:02
1e53ebf
Compare
Choose a tag to compare

Release Summary πŸ“

Version 0.3.1 updates all dependencies, adding support for Scala Native 0.4.0.

Change log πŸš€

v0.3.0

29 Sep 18:19
Compare
Choose a tag to compare

Release Summary πŸ“

Version 0.3.0 features several breaking changes. This release also adds support for Scala Native 0.4.0-M2 and Scala.js 1.2.0 while dropping artefacts for Scala Native 0.3.9 and Scala.js 0.6.

Migration Steps πŸ’»

The following route functions were renamed:

  1. parse() β†’ parseArgs()
  2. parseInternal() β†’ parse()

The second major change is that all routes now require exact matches, restoring the behaviour from before v0.2.0. If this is not desired, you can use the new matchers Elems or Params in your routes. Please refer to the manual for examples.

Change log πŸš€

  • Route: Require exact match when parsing (#39)
  • Build: Update dependencies (#41, by @lolgab)

v0.2.1

10 Jul 07:36
Compare
Choose a tag to compare

Release Summary πŸ“

Version 0.2.1 fixes various bugs. It also adds support for Scala 2.13.

Migration Steps πŸ’»

The API has not changed.

New Features πŸš€

  • Build: Add support for Scala 2.13 (#35)

Bug Fixes πŸ›

  • Route: Check path in parameter routes (#31)
  • Path: Fix parsing of empty query arguments (#32)
  • Route: Do not add ampersand if optional parameter is None (#33)
  • Route: Fix parsing of optional path elements (#34)

Documentation πŸ“•

  • Manual: Add example for encoding/decoding URI values (#36)

v0.2.0

05 Mar 07:43
Compare
Choose a tag to compare

Release Summary πŸ“

Version 0.2.0 features a number of user-facing changes. Trail now has zero dependencies, supports Scala Native and has better type inference. You can follow the links below to the pull requests for more information.

Migration Steps πŸ’»

Tuples instead HLists

Previously, route arguments were encoded using HLists:

url match {
  case Routes.index(HNil) => /// ...
  case Routes.details(id :: revision :: HNil) => // ...
}

Routes.details.url(1 :: 2 :: HNil)

Starting from v0.2.0, tuples are used instead:

url match {
  case Routes.index(()) => // ...
  case Routes.details((id, revision)) => // ...
}

Routes.details.url((1, 2))

Parsing precedence

Define two routes with the same prefix:

val route  = Root / "details"
val route2 = Root / "details" / Arg[Int]

Previously, route would only match the URL /details, but now it also matches any URL with this prefix, e.g. /details/42 or /details/a/b.

In your routing table, you will have to make sure that when matching two routes with the same prefix, the longer one has a higher precedence:

url match {
  case route2(id)) => // ...
  case route(()) => // ...
}

Optional arguments

ParamOpt[T] was dropped in favour of the more generic Param[Option[T]]. The route:

val route = Root & ParamOpt[Int]("test")

becomes:

val route = Root & Param[Option[Int]]("test")

Codecs

In v0.2.0, codecs can return optional values which will be skipped when creating the URL. Similarly, you can detect in decode() if no value was provided for an argument and return a default value.

implicit case object FooArg extends Codec[Foo] {
  override def encode(s: Foo): Option[String] = // ...
  override def decode(s: Option[String]): Option[Foo]] = // ...
}

New Features πŸš€

Support fragment identifiers (#26)

Fragment identifiers are frequently used for routing in single-page applications. In Trail routes, you can specify fragments using the $ sign:

val routeFragment = Root $ Fragment[Int]
routeFragment.parse("/#42")  // Some(42)

Provide parsed route (#27)

When you use the parse() or unapply() methods, you can now provide a trail.Path() argument as opposed to a string. If you already have a deconstructed URL, this will reduce the parsing overhead:

route.parse(trail.Path("/user/hello", List("show" -> "false")))

Use tuples instead of HLists (#29)

Instead of Shapeless HLists, v0.2.0 uses tuples for encoding types of path elements.

This change resulted in better IDE support and improved type inference. For example, you can construct route arguments with Some(x) where previously Option(x) was required:

val route = Root & Param[Option[Int]]("test")
route(Some(42))  // /?test=42

Also, conditional routes are supported. In v0.1, the following route would not have type-checked:

if (isProduction) Root / "api" / "v2.0" else Root

Add Scala Native support (#30)

As a consequence of the tuple refactoring, all external dependencies could be dropped which allows us to now fully support Scala Native.

Closed issues πŸ“•

#14, #20, #24, #25, #28