Uri

case
class Uri(scheme: Option[String], authority: Option[Authority], pathSegments: PathSegments, querySegments: Seq[QuerySegment], fragmentSegment: Option[Segment])

A URI. Can represent both relative and absolute URIs, hence in terms of https://tools.ietf.org/html/rfc3986, this is a URI reference.

All components (scheme, host, query, ...) are stored decoded, and become encoded upon serialization (using toString).

Instances can be created using the uri interpolator: uri"..." (see UriInterpolator), or the factory methods on the Uri companion object.

The apply/safeApply/unsafeApply methods create absolute URIs and require a host. The relative methods creates a relative URI, given path/query/fragment components.

Value Params
querySegments

Either key-value pairs, single values, or plain query segments. Key value pairs will be serialized as k=v, and blocks of key-value pairs/single values will be combined using &. Note that no & or other separators are added around plain query segments - if required, they need to be added manually as part of the plain query segment. Custom encoding logic can be provided when creating a segment.

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def addParam(k: String, v: String): Uri
def addParam(k: String, v: Option[String]): Uri
def addParams(ps: Map[String, String]): Uri
def addParams(ps: (String, String)*): Uri
def addPath(p: String, ps: String*): Uri
def addPath(ps: Seq[String]): Uri
def addPathSegments(ss: Seq[Segment]): Uri

Replace the authority.

Replace the authority.

def authority(a: Some[Authority]): Uri

Replace the authority.

Replace the authority.

def fragment(f: String): Uri

Replace the fragment.

Replace the fragment.

def fragment(f: Option[String]): Uri

Replace the fragment.

Replace the fragment.

def fragment: Option[String]
def fragmentSegment(s: Option[Segment]): Uri

Replace the fragment.

Replace the fragment.

def host(h: String): Uri

Replace the host. Does not validate the new host value if it's nonempty.

Replace the host. Does not validate the new host value if it's nonempty.

def host: Option[String]

Replace the host. Does not validate the new host value if it's nonempty.

Replace the host. Does not validate the new host value if it's nonempty.

def hostSegment(s: Option[Segment]): Uri

Replace the host. Does not validate the new host value if it's nonempty.

Replace the host. Does not validate the new host value if it's nonempty.

def isAbsolute: Boolean
def isRelative: Boolean
def paramsMap: Map[String, String]
def paramsSeq: Seq[(String, String)]
def path: Seq[String]
def port(p: Int): Uri

Replace the port. Adds an empty host if one is absent.

Replace the port. Adds an empty host if one is absent.

def port(p: Option[Int]): Uri

Replace the port. Adds an empty host if one is absent, and port is defined.

Replace the port. Adds an empty host if one is absent, and port is defined.

def port: Option[Int]

Replace encoding for query segments: applies to key-value, only-value and plain ones.

Replace encoding for query segments: applies to key-value, only-value and plain ones.

Replace encoding for the value part of key-value query segments and for only-value ones.

Replace encoding for the value part of key-value query segments and for only-value ones.

def resolve(other: Uri): Uri
def scheme(s: String): Uri

Replace the scheme. Does not validate the new scheme value.

Replace the scheme. Does not validate the new scheme value.

def scheme(s: Option[String]): Uri

Replace the scheme. Does not validate the new scheme value.

Replace the scheme. Does not validate the new scheme value.

def toJavaUri: URI
override
def toString: String
Definition Classes
Any
def userInfo(username: String): Uri

Replace the user info with a username only. Adds an empty host if one is absent.

Replace the user info with a username only. Adds an empty host if one is absent.

def userInfo(username: String, password: String): Uri

Replace the user info with username/password combination. Adds an empty host if one is absent.

Replace the user info with username/password combination. Adds an empty host if one is absent.

def userInfo(ui: Option[UserInfo]): Uri

Replace the user info with username/password combination. Adds an empty host if one is absent, and user info is defined.

Replace the user info with username/password combination. Adds an empty host if one is absent, and user info is defined.

def userInfo: Option[UserInfo]
def withParam(k: String, v: String): Uri

Replace query with the given single parameter.

Replace query with the given single parameter.

def withParam(k: String, v: Option[String]): Uri

Replace query with the given single optional parameter.

Replace query with the given single optional parameter.

def withParams(ps: Map[String, String]): Uri

Replace query with the given parameters.

Replace query with the given parameters.

Replace query with the given parameters.

Replace query with the given parameters.

def withParams(ps: (String, String)*): Uri

Replace query with the given parameters.

Replace query with the given parameters.

def withPath(p: String, ps: String*): Uri
def withPath(ps: Seq[String]): Uri
def withWholePath(p: String): Uri

Replace the whole path with the given one. Leading / will be removed, if present, and the path will be split into segments on /.

Replace the whole path with the given one. Leading / will be removed, if present, and the path will be split into segments on /.

Deprecated methods

@deprecated(message = "Use addParam or withParam", since = "1.2.0")
def param(k: String, v: String): Uri

Adds the given parameter to the query.

Adds the given parameter to the query.

Deprecated
[Since version 1.2.0] Use addParam or withParam
@deprecated(message = "Use addParam or withParam", since = "1.2.0")
def param(k: String, v: Option[String]): Uri

Adds the given parameter with an optional value to the query if it is present.

Adds the given parameter with an optional value to the query if it is present.

Deprecated
[Since version 1.2.0] Use addParam or withParam
@deprecated(message = "Use addParam or withParam", since = "1.2.0")
def params(ps: Map[String, String]): Uri

Adds the given parameters to the query.

Adds the given parameters to the query.

Deprecated
[Since version 1.2.0] Use addParam or withParam
@deprecated(message = "Use addParam or withParam", since = "1.2.0")

Adds the given parameters to the query.

Adds the given parameters to the query.

Deprecated
[Since version 1.2.0] Use addParam or withParam
@deprecated(message = "Use addParam or withParam", since = "1.2.0")
def params(ps: (String, String)*): Uri

Adds the given parameters to the query.

Adds the given parameters to the query.

Deprecated
[Since version 1.2.0] Use addParam or withParam
@deprecated(message = "Use addPath, withPath or withWholePath", since = "1.2.0")
def path(p: String): Uri

Replace path with the given single-segment path.

Replace path with the given single-segment path.

Deprecated
[Since version 1.2.0] Use addPath, withPath or withWholePath
@deprecated(message = "Use addPath, withPath or withWholePath", since = "1.2.0")
def path(p1: String, p2: String, ps: String*): Uri

Replace path with the given path segments.

Replace path with the given path segments.

Deprecated
[Since version 1.2.0] Use addPath, withPath or withWholePath
@deprecated(message = "Use addPath, withPath or withWholePath", since = "1.2.0")
def path(ps: Seq[String]): Uri

Replace path with the given path segments.

Replace path with the given path segments.

Deprecated
[Since version 1.2.0] Use addPath, withPath or withWholePath
@deprecated(message = "Use addPath, withPath or withWholePath", since = "1.2.0")

Replace path with the given path segment.

Replace path with the given path segment.

Deprecated
[Since version 1.2.0] Use addPath, withPath or withWholePath
@deprecated(message = "Use addPath, withPath or withWholePath", since = "1.2.0")
def pathSegments(s1: Segment, s2: Segment, ss: Segment*): Uri

Replace path with the given path segment.

Replace path with the given path segment.

Deprecated
[Since version 1.2.0] Use addPath, withPath or withWholePath
@deprecated(message = "Use addPath, withPath or withWholePath", since = "1.2.0")
def pathSegments(ss: Seq[Segment]): Uri

Replace path with the given path segments.

Replace path with the given path segments.

Deprecated
[Since version 1.2.0] Use addPath, withPath or withWholePath
@deprecated(message = "Use addQuerySegment", since = "1.2.0")

Adds the given query segment.

Adds the given query segment.

Deprecated
[Since version 1.2.0] Use addQuerySegment

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product