Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route: Only encode placeholders in type parameter #29

Merged
merged 1 commit into from
Mar 1, 2019
Merged

Conversation

tindzk
Copy link
Member

@tindzk tindzk commented Feb 27, 2019

Previously, static path elements were encoded in Route's HList.
This prevented conditional routes such as the following:

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

Change the implementation such that only placeholders (e.g.
Arg[String] or Fragment[Int]) are encoded in Route's type
parameter.

Also, simplify the design by using tuples instead of HLists. As a
consequence, the compile-time and run-time footprint is reduced.

Detailed changes:

  • Use tuples instead of HLists
  • Eliminate all type casts
  • Drop all external dependencies (Shapeless, Cats)
  • Argument and fragment placeholders are now encoded in Route's
    type parameter
  • Change fragment delimiter from # to $
  • Route parsing does not fail anymore when additional path elements
    are specified
  • Drop ParamOpt[T] in favour of Param[Option[T]]
  • Optional route arguments can now be populated with None instead
    of Option.empty[T]
  • Remove all type aliases
  • Custom Codecs can read/emit optional arguments

Closes #14.
Closes #28.

@tindzk tindzk force-pushed the issue/28 branch 2 times, most recently from a47a3ee to 8a780ee Compare February 27, 2019 12:33
Previously, static path elements were encoded in `Route`'s `HList`.
This prevented conditional routes such as the following:

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

Change the implementation such that only placeholders (e.g.
`Arg[String]` or `Fragment[Int]`) are encoded in `Route`'s type
parameter.

Also, simplify the design by using tuples instead of `HList`s. As a
consequence, the compile-time and run-time footprint is reduced.

**Detailed changes:**
- Use tuples instead of `HList`s
- Eliminate all type casts
- Drop all external dependencies (Shapeless, Cats)
- Argument and fragment placeholders are now encoded in `Route`'s
  type parameter
- Change fragment delimiter from `#` to `$`
- Route parsing does not fail anymore when additional path elements
  are specified
- Drop `ParamOpt[T]` in favour of `Param[Option[T]]`
- Optional route arguments can now be populated with `None` instead
  of `Option.empty[T]`
- Remove all type aliases
- Custom `Codec`s can read/emit optional arguments

Closes #14.
Closes #28.
@tindzk tindzk merged commit e7be86b into master Mar 1, 2019
@tindzk tindzk deleted the issue/28 branch March 1, 2019 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant