Skip to content

Commit 9e84a78

Browse files
committed
📝 Adapt documentation for 0.7.0 about breaking change
1 parent b556173 commit 9e84a78

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We represent the path and query parameters of a url as follows:
1010
import urldsl.language.simpleErrorImpl._
1111
import urldsl.vocabulary.{Segment, Param, UrlMatching}
1212

13-
val path = root / "hello" / segment[Int] / segment[String] / endOfSegments
13+
val path = root / "hello" / segment[Int] / segment[String]
1414
val params = param[Int]("age") & listParam[String]("drinks")
1515

1616
val pathWithParams = path ? params
@@ -96,17 +96,19 @@ passes the rest onto the following (when there are composed). For example, if yo
9696
string "foo", and an other that matches an `Int`, if you give the composition "foo/22", the first `PathSegment` consumes
9797
"foo" and passes "22" to the next one, which will them consume it.
9898

99+
> Important (since 0.7.0 💥): the `PathSegment` has to fully match the path in order to succeed. If there is a left over segment after, then it will not match. You can use `ignoreRemainingSegments` if you want to only match the "beginning" of the path.
100+
99101
#### Built in path segments
100102

101103
There are a bunch of `PathSegment`s that are already defined, and should satisfy most of your basic needs. For example,
102104
the following things are implemented (you can look at the companion object of `PathSegment` to have the comprehensive
103-
list:
105+
list):
104106

105107
- `root`: matches everything and passes all segments onto the next
106108
- `segment[T]` matches an element of type `T`, whose information is contained in only one segment, and passes the other
107109
segments onto the next
108-
- `endOfSegments`: which matches only the empty list of segments, and thus passes nothing onto the next (there should
109-
never be a next, though)
110+
- `remainingSegments`: consumes all the remaining segments, returning the list
111+
- `ignoreRemainingSegments`: consumes all the remaining segments and ignore their content
110112
- the list goes on...
111113

112114
#### Examples
@@ -278,6 +280,10 @@ import urldsl.language.dummyErrorImpl._
278280

279281
url-dsl was thought with one possible goal in mind, the one of creating a routing system. An example of how to do that can be found [here](shared/src/test/scala/urldsl/examples/RouterUseCaseExample.scala).
280282

283+
## Moving from 0.6.x to 0.7.x
284+
285+
There is a breaking change introduced in 0.7.0. If a `PathSegment` only partially match the path, then it will fail. If you were relying on this behaviour, you need to add `/ ignoreRemainingSegments` to your `PathSegment` instances.
286+
281287
## Moving from 0.4.x to 0.5.x
282288

283289
In 0.5.0 we replaced our `Tupler` with the `Composition` type from the [tuplez](https://github.com/tulz-app/tuplez) library. It works exactly the same for most use cases, but if your data types are complex enough that URL-DSL previously gave you nested tuples, those tuples will generally be flattened now.

0 commit comments

Comments
 (0)