All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.config.Authority.kt Maven / Gradle / Ivy

There is a newer version: 5.41.0.0
Show newest version
package org.http4k.config

data class Authority(val host: Host, val port: Port? = null) {
    override fun toString() = host.value + (port?.let { ":${it.value}" }.orEmpty())

    companion object {
        operator fun invoke(value: String) = with(value.split(":")) {
            when (size) {
                1 -> Authority(Host(this[0]), null)
                2 -> Authority(Host(this[0]), Port(this[1].toInt()))
                else -> throw IllegalArgumentException("Could not construct Authority from $value")
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy