URLBuilder

class URLBuilder

A URL builder with all mutable components

Constructors

<init>

URLBuilder(
    protocol: URLProtocol = URLProtocol.HTTP,
    host: String = "localhost",
    port: Int = DEFAULT_PORT,
    user: String? = null,
    password: String? = null,
    encodedPath: String = "/",
    parameters: ParametersBuilder = ParametersBuilder(),
    fragment: String = "",
    trailingQuery: Boolean = false)

A URL builder with all mutable components

Properties

encodedPath

var encodedPath: String

encoded URL path without query

fragment

var fragment: String

URL fragment (anchor name)

host

var host: String

name without port (domain)

parameters

val parameters: ParametersBuilder

URL query parameters

password

var password: String?

password part (optional)

port

var port: Int

port number

protocol

var protocol: URLProtocol

URL protocol (scheme)

trailingQuery

var trailingQuery: Boolean

keep a trailing question character even if there are no query parameters

user

var user: String?

username part (optional)

Functions

build

fun build(): Url

Build a Url instance (everything is copied to a new instance)

buildString

fun buildString(): String

Build a URL string

path

fun path(vararg components: String): URLBuilder
fun path(components: List<String>): URLBuilder

Encode components to encodedPath

Extension Functions

clone

fun URLBuilder.clone(): URLBuilder

Create a copy of this builder. Modifications in a copy is not reflected in the original instance and vise-versa.

takeFrom

fun URLBuilder.takeFrom(urlString: String): URLBuilder

Take url parts from urlString throws URLParserException

fun URLBuilder.takeFrom(url: URLBuilder): URLBuilder

Take components from another url builder

fun URLBuilder.takeFrom(url: Url): URLBuilder

Take components from another url

fun URLBuilder.takeFrom(uri: URI): Unit

Take URI components from uri

fun URLBuilder.takeFrom(url: URL): Unit

Take URI components from url

Companion Object Extension Functions

createFromCall

fun URLBuilder.Companion.createFromCall(
    call: ApplicationCall
): URLBuilder

Creates an url using current call’s schema, path and parameters as initial