org.http4k.lens.configExt.kt Maven / Gradle / Ivy
package org.http4k.lens
import org.http4k.config.Authority
import org.http4k.config.Host
import org.http4k.config.Port
import org.http4k.config.Secret
import org.http4k.config.Timeout
fun StringBiDiMappings.host() = nonBlank().map(::Host, Host::value)
fun StringBiDiMappings.port() = int().map(::Port, Port::value)
fun StringBiDiMappings.authority() = nonBlank().map({ Authority(it) }, Authority::toString)
fun StringBiDiMappings.secret() = nonEmpty().map({ Secret(it) }, { secret -> secret.use { it } })
fun BiDiLensSpec.secret() = map(StringBiDiMappings.secret())
fun BiDiLensSpec.host() = map(StringBiDiMappings.host())
fun BiDiLensSpec.port() = map(StringBiDiMappings.port())
fun BiDiLensSpec.authority() = map(StringBiDiMappings.authority())
fun BiDiLensSpec.timeout() = duration().map(::Timeout, Timeout::value)
val Header.HOST get() = Header.authority().optional("host")