trait Urls extends PartialInvariantFunctorSyntax
Algebra interface for describing URLs made of a path and a query string.
A path is itself made of segments chained together.
A query string is made of named parameters.
/** * Describes an URL starting with a segment containing “articles”, followed * by another `String` segment, and a query string containing * a mandatory `Lang` parameter named “lang”, and an * optional `Int` parameter named “page”. * * Examples of matching URLs: * * - /articles/kitchen?lang=fr * - /articles/garden?lang=en&page=2 */ val example = path / "articles" / segment[String]() /? (qs[Lang]("lang") & qs[Option[Int]]("page"))
- Source
- Urls.scala
- Alphabetic
- By Inheritance
- Urls
- PartialInvariantFunctorSyntax
- InvariantFunctorSyntax
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
implicit
class
InvariantFunctorSyntax[A, F[_]] extends AnyRef
- Definition Classes
- InvariantFunctorSyntax
-
implicit
class
PartialInvariantFunctorSyntax[A, F[_]] extends AnyRef
- Definition Classes
- PartialInvariantFunctorSyntax
-
abstract
type
Path[A] <: Url[A]
An URL path carrying an
A
informationAn URL path carrying an
A
informationValues of type
Path[A]
can be constructed by the operations path, segment, and remainingSegments.path / "user" / segment[UUID]("id")
- Server interpreters raise an error if they can’t parse the incoming
request path as a value of type
A
. By default, they produce a Bad Request (400) response with a list of error messages in a JSON array. Refer to the documentation of your server interpreter to customize this behavior.
- Note
This type has implicit methods provided by the PathOps, InvariantFunctorSyntax, and the PartialInvariantFunctorSyntax classes.
- Server interpreters raise an error if they can’t parse the incoming
request path as a value of type
-
implicit
class
PathOps[A] extends AnyRef
Convenient methods for Paths.
-
abstract
type
QueryString[A]
A query string carrying an
A
informationA query string carrying an
A
informationQueryString values can be created with the qs operation, and can be combined with the
&
operation:val queryPageAndLang: QueryString[(Int, Option[String])] = qs[Int]("page") & qs[Option[String]]("lang")
- Server interpreters raise an error if they can’t parse the incoming
request query string parameters as a value of type
A
. By default, they produce a Bad Request (400) response with a list of error messages in a JSON array. Refer to the documentation of your server interpreter to customize this behavior.
- Note
This type has implicit methods provided by the QueryStringSyntax, InvariantFunctorSyntax, and the PartialInvariantFunctorSyntax classes.
- Server interpreters raise an error if they can’t parse the incoming
request query string parameters as a value of type
-
abstract
type
QueryStringParam[A]
A query string parameter codec for type
A
.A query string parameter codec for type
A
.The trait
Urls
provides implicit instances of typeQueryStringParam[A]
for basic types (e.g.,Int
,String
, etc.). You can create additional instances by transforming or refining the existing instances withxmap
andxmapPartial
.- Note
This type has implicit methods provided by the PartialInvariantFunctorSyntax and the InvariantFunctorSyntax classes.
-
implicit
class
QueryStringSyntax[A] extends AnyRef
Extension methods on QueryString.
-
abstract
type
Segment[A]
An URL path segment codec for type
A
.An URL path segment codec for type
A
.The trait
Urls
provides implicit instances ofSegment[A]
for basic types (e.g.,Int
,String
, etc.). You can create additional instances by transforming or refining the existing instances withxmap
andxmapPartial
.- Note
This type has implicit methods provided by the PartialInvariantFunctorSyntax and the InvariantFunctorSyntax classes.
-
abstract
type
Url[A]
An URL carrying an
A
informationAn URL carrying an
A
informationValues of type
URL[A]
are typically constructed by first using the path constructor and then chaining it with segments and query parameters.path / "users" / segment[UUID]("id") /? qs[String]("apiKey")
- Server interpreters raise an error if they can’t parse the incoming
request URL as a value of type
A
. By default, they produce a Bad Request (400) response with a list of error messages in a JSON array. Refer to the documentation of your server interpreter to customize this behavior.
- Note
This type has implicit methods provided by the PartialInvariantFunctorSyntax and InvariantFunctorSyntax classes.
- Server interpreters raise an error if they can’t parse the incoming
request URL as a value of type
Abstract Value Members
-
abstract
def
chainPaths[A, B](first: Path[A], second: Path[B])(implicit tupler: Tupler[A, B]): Path[Out]
Chains the two paths
-
abstract
def
combineQueryStrings[A, B](first: QueryString[A], second: QueryString[B])(implicit tupler: Tupler[A, B]): QueryString[Out]
Concatenates two
QueryString
s -
implicit abstract
def
optionalQueryStringParam[A](implicit arg0: QueryStringParam[A]): QueryStringParam[Option[A]]
Make a query string parameter optional:
Make a query string parameter optional:
path / "articles" /? qs[Option[Int]]("page")
- Client interpreters must omit optional query string parameters that are empty.
- Server interpreters must accept incoming requests whose optional query string parameters are missing, and they must report a failure for incoming requests whose optional query string parameters are present, but malformed,
- Documentation interpreters should mark the parameter as optional.
-
implicit abstract
def
pathPartialInvariantFunctor: PartialInvariantFunctor[Path]
Provides
xmap
andxmapPartial
operations.Provides
xmap
andxmapPartial
operations.- See also
-
abstract
def
qs[A](name: String, docs: Documentation = None)(implicit value: QueryStringParam[A]): QueryString[A]
Builds a
QueryString
with one parameter.Builds a
QueryString
with one parameter.Examples:
qs[Int]("page") // mandatory `page` parameter qs[Option[String]]("lang") // optional `lang` parameter qs[List[Long]]("id") // repeated `id` parameter
- A
Type of the value carried by the parameter
- name
Parameter’s name
-
implicit abstract
def
queryStringParamPartialInvariantFunctor: PartialInvariantFunctor[QueryStringParam]
Provides
xmap
andxmapPartial
operations.Provides
xmap
andxmapPartial
operations.- See also
-
implicit abstract
def
queryStringPartialInvariantFunctor: PartialInvariantFunctor[QueryString]
Provides
xmap
andxmapPartial
operations.Provides
xmap
andxmapPartial
operations.- See also
-
abstract
def
remainingSegments(name: String = "", docs: Documentation = None): Path[String]
The remaining segments of the path.
The remaining segments of the path. The
String
value carried by thisPath
is still URL-encoded. -
implicit abstract
def
repeatedQueryStringParam[A, CC[X] <: Iterable[X]](implicit arg0: QueryStringParam[A], factory: scala.collection.compat.Factory[A, CC[A]]): QueryStringParam[CC[A]]
Support query string parameters with multiple values:
Support query string parameters with multiple values:
path / "articles" /? qs[List[Long]]("id")
- Server interpreters must accept incoming requests where such parameters are missing (in such a case, its value is an empty collection), and report a failure if at least one value is malformed.
-
abstract
def
segment[A](name: String = "", docs: Documentation = None)(implicit s: Segment[A]): Path[A]
A path segment carrying an
A
information -
implicit abstract
def
segmentPartialInvariantFunctor: PartialInvariantFunctor[Segment]
Provides
xmap
andxmapPartial
operations.Provides
xmap
andxmapPartial
operations.- See also
-
abstract
def
staticPathSegment(segment: String): Path[Unit]
A path segment whose value is the given
segment
-
implicit abstract
def
stringQueryString: QueryStringParam[String]
Ability to define
String
query string parameters -
implicit abstract
def
stringSegment: Segment[String]
Path segment codec for type
String
Path segment codec for type
String
- Server interpreters should return an URL-decoded string value,
- Client interpreters should take an URL-decoded string value.
-
implicit abstract
def
urlPartialInvariantFunctor: PartialInvariantFunctor[Url]
Provides
xmap
andxmapPartial
operationsProvides
xmap
andxmapPartial
operations- See also
-
abstract
def
urlWithQueryString[A, B](path: Path[A], qs: QueryString[B])(implicit tupler: Tupler[A, B]): Url[Out]
Builds an URL from the given path and query string
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
implicit
def
booleanQueryString: QueryStringParam[Boolean]
Query string parameter containing a
Boolean
value -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
implicit
def
doubleQueryString: QueryStringParam[Double]
Codec for query string parameters of type
Double
-
implicit
def
doubleSegment: Segment[Double]
Path segment codec for type
Double
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
implicit
def
intQueryString: QueryStringParam[Int]
Ability to define
Int
query string parameters -
implicit
def
intSegment: Segment[Int]
Path segment codec for type
Int
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
implicit
def
longQueryString: QueryStringParam[Long]
Query string parameter containing a
Long
value -
implicit
def
longSegment: Segment[Long]
Path segment codec for type
Long
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
val
path: Path[Unit]
An empty path.
An empty path.
Useful to begin a path definition:
path / "foo" / segment[Int] /? qs[String]("bar")
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
implicit
def
uuidQueryString: QueryStringParam[UUID]
Ability to define
UUID
query string parameters -
implicit
def
uuidSegment: Segment[UUID]
Path segment codec for type
UUID
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Inherited from endpoints.PartialInvariantFunctorSyntax
Inherited from endpoints.InvariantFunctorSyntax
Inherited from AnyRef
Inherited from Any
Types
Types introduced by the algebra
Operations
Operations creating and transforming values