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
- Grouped
- Alphabetic
- By Inheritance
- Urls
- PartialInvariantFunctorSyntax
- InvariantFunctorSyntax
- AnyRef
- Any
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit class InvariantFunctorSyntax[A, F[_]] extends AnyRef
Extension methods for values of type
F[A]
for which there is an implicitInvariantFunctor[F]
instance.Extension methods for values of type
F[A]
for which there is an implicitInvariantFunctor[F]
instance.- 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
information- Note
This type has implicit methods provided by the PathOps, InvariantFunctorSyntax, and the PartialInvariantFunctorSyntax classes.
- 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")
- Note
This type has implicit methods provided by the QueryStringSyntax, InvariantFunctorSyntax, and the PartialInvariantFunctorSyntax classes.
- abstract type QueryStringParam[A]
A query string parameter codec for type
A
.A query string parameter codec for type
A
.- 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
.- 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
information- Note
This type has implicit methods provided by the PartialInvariantFunctorSyntax and InvariantFunctorSyntax classes.
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. Server interpreters must report a failure for incoming requests whose optional query string parameters are present, but malformed.
- 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: 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]
Ability to define
String
path segments Servers should return an URL-decoded string value, and clients 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
- def ->[B](y: B): (Urls, B)
- 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(classOf[java.lang.CloneNotSupportedException]) @native()
- implicit def doubleQueryString: QueryStringParam[Double]
Codec for query string parameters of type
Double
- implicit def doubleSegment: Segment[Double]
Segment codec for type
Double
- implicit def dummyPathToUrl[A](p: Path[A]): Url[A]
Implicit conversion to get rid of intellij errors when defining paths.
Implicit conversion to get rid of intellij errors when defining paths. Effectively should not be called.
- def ensuring(cond: (Urls) => Boolean, msg: => Any): Urls
- def ensuring(cond: (Urls) => Boolean): Urls
- def ensuring(cond: Boolean, msg: => Any): Urls
- def ensuring(cond: Boolean): Urls
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def formatted(fmtstr: String): String
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- implicit def intQueryString: QueryStringParam[Int]
Ability to define
Int
query string parameters - implicit def intSegment: Segment[Int]
Ability to define
Int
path segments - 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]
Segment containing a
Long
value - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- 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
- def tryParseString[A](type: String)(parse: (String) => A): (String) => Validated[A]
- implicit def uuidQueryString: QueryStringParam[UUID]
Ability to define
UUID
query string parameters - implicit def uuidSegment: Segment[UUID]
Ability to define
UUID
path segments - final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def →[B](y: B): (Urls, B)
- Implicit
- This member is added by an implicit conversion from Urls toArrowAssoc[Urls] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
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