Represents a part of the path string of an URL, containing an information of type T, or an error of type A.
Represents a part of the path string of an URL, containing an information of type T, or an error of type A.
- Type Params
- A
type of the error that this PathSegment produces on "illegal" url paths.
- T
type represented by this PathSegment
- Companion
- object
Value members
Abstract methods
Generate a list of segments representing the argument t
.
Generate a list of segments representing the argument t
.
matchSegments
and createSegments
should be (functional) inverse of each other. That is,
this.matchSegments(this.createSegments(t)) == Right(PathMathOutput(t, Nil))
Tries to match the list of urldsl.vocabulary.Segments to create an instance of T
.
If it can not, it returns an error indicating the reason of the failure.
If it could, it returns the value of T
, as well as the list of unused segments.
Tries to match the list of urldsl.vocabulary.Segments to create an instance of T
.
If it can not, it returns an error indicating the reason of the failure.
If it could, it returns the value of T
, as well as the list of unused segments.
- Value Params
- segments
The list of urldsl.vocabulary.Segment to match this path segment again.
- Returns
The "de-serialized" element with unused segment, if successful.
- Example
For example, a segment that matches simply a String in the first segment, when giving segments like List(Segment("hello"), Segment("3")) will return Right(PathMatchOutput("hello", List(Segment("3")))
Concrete methods
Concatenates this
urldsl.language.PathSegment with that
one, "tupling" the types with the Tupler
rules.
Concatenates this
urldsl.language.PathSegment with that
one, "tupling" the types with the Tupler
rules.
Casts this PathSegment to the new type U. Note that the urldsl.vocabulary.Codec must be an exception-free bijection between T and U (or at least an embedding, if you know that you are doing).
Casts this PathSegment to the new type U. Note that the urldsl.vocabulary.Codec must be an exception-free bijection between T and U (or at least an embedding, if you know that you are doing).
Casts this PathSegment to the new type U. The conversion functions should form an exception-free bijection between T and U (or at least an embedding, if you know that you are doing).
Casts this PathSegment to the new type U. The conversion functions should form an exception-free bijection between T and U (or at least an embedding, if you know that you are doing).
Concatenates the segments generated by createSegments
Concatenates the segments generated by createSegments
Adds an extra satisfying criteria to the de-serialized output of this urldsl.language.PathSegment.
Adds an extra satisfying criteria to the de-serialized output of this urldsl.language.PathSegment.
The new de-serialization works as follows:
- if the initial de-serialization fails, then it returns the generated error
- otherwise, if the de-serialized element satisfies the predicate, then it returns the element
- if the predicate is false, generates the given
error
by feeding it the segments that it tried to match.
This can be useful in, among others, two scenarios:
- enforce bigger restriction on a segment (e.g., from integers to positive integer, regex match...)
- in a multi-part segment, ensure consistency between the different component (e.g., a range of two integers that should not be too large...)
Matches using this PathSegment, and then forgets its content.
Uses the default
value when creating the path to go back.
Matches using this PathSegment, and then forgets its content.
Uses the default
value when creating the path to go back.
Matches the given raw url
using the given urldsl.url.UrlStringParserGenerator for creating a
urldsl.url.UrlStringParser.
Matches the given raw url
using the given urldsl.url.UrlStringParserGenerator for creating a
urldsl.url.UrlStringParser.
This method doesn't return the information about the remaining unused segments. The thought leading to this is that urldsl.vocabulary.PathMatchOutput are supposed to be internal mechanics, while this method is supposed to be the exposed interface of this urldsl.language.PathSegment.
- Value Params
- url
the url to parse. It has to be a well formed URL, otherwise this could raise an exception, depending on the provided urldsl.url.UrlStringParserGenerator.
- urlStringParserGenerator
the urldsl.url.UrlStringParserGenerator used to create the urldsl.url.UrlStringParser that will actually parse the url to create the segments. The default one is usually a good choice. It has different implementations in JVM and JS, but they should behave the same way.
- Returns
the output contained in the url, or the error if something fails.
Forgets the information contained in the path parameter by injecting one. This turn this "dynamic" PathSegment into a fix one.
Forgets the information contained in the path parameter by injecting one. This turn this "dynamic" PathSegment into a fix one.
Associates this PathSegment with the given Fragment in order to match raw urls satisfying both conditions, and returning the outputs from both.
Associates this PathSegment with the given Fragment in order to match raw urls satisfying both conditions, and returning the outputs from both.
The query part of the url will be ignored (and will return Unit).
Builds a PathSegment that first tries to match with this one, then tries to match with that
one.
If both fail, the error of the second is returned (todo[behaviour]: should that change?)
Builds a PathSegment that first tries to match with this one, then tries to match with that
one.
If both fail, the error of the second is returned (todo[behaviour]: should that change?)