Package-level declarations

Types

Link copied to clipboard

A BiDiBodyLens provides the bi-directional extraction of an entity from a target body, or the insertion of an entity into a target body.

Link copied to clipboard
open class BiDiBodyLensSpec<OUT>(metas: List<Meta>, contentType: ContentType, get: LensGet<HttpMessage, OUT>, set: LensSet<HttpMessage, OUT>) : BodyLensSpec<OUT>

Represents a bi-directional extraction of an entity from a target Body, or an insertion into a target Body.

Link copied to clipboard
class BiDiLens<in IN : Any, FINAL>(meta: Meta, get: (IN) -> FINAL, lensSet: (FINAL, IN) -> IN) : Lens<IN, FINAL> , LensInjectorExtractor<IN, FINAL>

A BiDiLens provides the bi-directional extraction of an entity from a target, or the insertion of an entity into a target.

Link copied to clipboard
Link copied to clipboard
open class BiDiLensSpec<IN : Any, OUT>(location: String, paramMeta: ParamMeta, get: LensGet<IN, OUT>, set: LensSet<IN, OUT>) : LensSpec<IN, OUT> , BiDiLensBuilder<IN, OUT>

Represents a bi-directional extraction of an entity from a target, or an insertion into a target.

Link copied to clipboard
open class BiDiMapping<IN, OUT>(val clazz: Class<OUT>, val asOut: (IN) -> OUT, val asIn: (OUT) -> IN)

A BiDiMapping defines a reusable bidirectional transformation between an input and output type

Link copied to clipboard

Represents a bi-directional extraction of a list of entities from a target, or an insertion into a target.

Link copied to clipboard
Link copied to clipboard
open class BiDiPathLensSpec<OUT>(paramMeta: ParamMeta, get: LensGet<String, OUT>, set: LensSet<Request, OUT>) : PathLensSpec<OUT>
Link copied to clipboard
open class BodyLens<out FINAL>(val metas: List<Meta>, val contentType: ContentType, getLens: (HttpMessage) -> FINAL) : LensExtractor<HttpMessage, FINAL>

A BodyLens provides the uni-directional extraction of an entity from a target body.

Link copied to clipboard
open class BodyLensSpec<out OUT>(metas: List<Meta>, contentType: ContentType, get: LensGet<HttpMessage, OUT>)

Represents a uni-directional extraction of an entity from a target Body.

Link copied to clipboard
fun interface ContentNegotiation

Modes for determining if a passed content type is acceptable.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
sealed class Failure
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
typealias HeaderLens<T> = Lens<HttpMessage, T>
Link copied to clipboard
data class Invalid(val meta: Meta) : Failure
Link copied to clipboard
open class Lens<in IN : Any, out FINAL>(val meta: Meta, lensGet: (IN) -> FINAL) : LensExtractor<IN, FINAL> , Iterable<Meta>

A Lens provides the uni-directional extraction of an entity from a target.

Link copied to clipboard
interface LensBuilder<IN : Any, OUT>

Common construction patterns for all lens implementations.

Link copied to clipboard
fun interface LensExtractor<in IN, out OUT> : Function1<IN, OUT>
Link copied to clipboard
class LensFailure(val failures: List<Failure>, val cause: Exception? = null, val target: Any? = null, message: String = failures.joinToString { it.toString() }) : Exception
Link copied to clipboard
data class LensFailures(val causes: List<LensFailure>) : RuntimeException
Link copied to clipboard
class LensGet<in IN, out OUT>
Link copied to clipboard
interface LensInjector<in IN, in OUT>
Link copied to clipboard
Link copied to clipboard
class LensSet<IN, in OUT>
Link copied to clipboard
open class LensSpec<IN : Any, OUT>(val location: String, paramMeta: ParamMeta, get: LensGet<IN, OUT>) : LensBuilder<IN, OUT>

Represents a uni-directional extraction of an entity from a target.

Link copied to clipboard
data class Meta(val required: Boolean, val location: String, val paramMeta: ParamMeta, val name: String, val description: String?, val metadata: Map<String, Any>)
Link copied to clipboard
data class Missing(val meta: Meta) : Failure
Link copied to clipboard
sealed class ParamMeta
Link copied to clipboard
Link copied to clipboard
open class PathLens<out FINAL>(meta: Meta, get: (String) -> FINAL) : Lens<Request, FINAL>
Link copied to clipboard
open class PathLensSpec<out OUT>(paramMeta: ParamMeta, get: LensGet<String, OUT>)

Represents a uni-directional extraction of an entity from a target path segment.

Link copied to clipboard
typealias Prop<OUT> = ReadOnlyProperty<Any?, OUT>
Link copied to clipboard
Link copied to clipboard
typealias QueryLens<T> = Lens<Request, T>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A set of standardised String <-> Type conversions which are used throughout http4k

Link copied to clipboard
data class Unsupported(val meta: Meta) : Failure
Link copied to clipboard

Runs through a list of lenses and extracts the values from each one, collecting the errors

Link copied to clipboard
data class WebForm(val fields: Map<String, List<String>> = emptyMap(), val errors: List<Failure> = emptyList())

Functions

Link copied to clipboard
Link copied to clipboard

Convert the result of a lens extraction to a Result4k type which

Link copied to clipboard
Link copied to clipboard
fun Request.bearerAuth(token: String, scheme: String = "Bearer"): Request
Link copied to clipboard
Link copied to clipboard
fun Body.Companion.binary(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<InputStream>
Link copied to clipboard
Link copied to clipboard
inline fun <TARGET : Any, T> BiDiLensSpec<TARGET, String>.composite(crossinline fn: BiDiLensSpec<TARGET, String>.(TARGET) -> T): Lens<TARGET, T>

This allows creation of a composite object from several values from the same source.

inline fun <TARGET : Any, T> BiDiLensSpec<TARGET, String>.composite(crossinline getFn: BiDiLensSpec<TARGET, String>.(TARGET) -> T, crossinline setFn: T.(TARGET) -> TARGET): BiDiLens<TARGET, T>
Link copied to clipboard
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.csv(delimiter: String = ","): BiDiLensSpec<IN, List<String>>
fun <IN : Any, T : Any> BiDiLensSpec<IN, String>.csv(delimiter: String = ",", mapElement: BiDiMapping<String, T>): BiDiLensSpec<IN, List<T>>
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.dateTime(formatter: DateTimeFormatter = ISO_LOCAL_DATE_TIME): BiDiLensSpec<IN, LocalDateTime>
fun Path.dateTime(formatter: DateTimeFormatter = ISO_LOCAL_DATE_TIME): BiDiPathLensSpec<LocalDateTime>
Link copied to clipboard
Link copied to clipboard
inline fun <IN : Any, T : Enum<T>> BiDiLensSpec<IN, String>.enum(): BiDiLensSpec<IN, T>
inline fun <T : Enum<T>> Header.enum(caseSensitive: Boolean = true): BiDiLensSpec<HttpMessage, T>
inline fun <T : Enum<T>> Path.enum(caseSensitive: Boolean = true): BiDiPathLensSpec<T>
inline fun <T : Enum<T>> Query.enum(caseSensitive: Boolean = true): BiDiLensSpec<Request, T>
inline fun <IN : Any, T : Enum<T>> BiDiLensSpec<IN, String>.enum(noinline nextOut: (String) -> T, noinline nextIn: (T) -> String): BiDiLensSpec<IN, T>
inline fun <T : Enum<T>> Path.enum(noinline nextOut: (String) -> T, noinline nextIn: (T) -> String): BiDiPathLensSpec<T>
Link copied to clipboard
Link copied to clipboard
fun httpBodyRoot(metas: List<Meta>, acceptedContentType: ContentType, contentNegotiation: ContentNegotiation): BiDiBodyLensSpec<Body>
Link copied to clipboard
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.localDate(formatter: DateTimeFormatter = ISO_LOCAL_DATE): BiDiLensSpec<IN, LocalDate>
fun Path.localDate(formatter: DateTimeFormatter = ISO_LOCAL_DATE): BiDiPathLensSpec<LocalDate>
Link copied to clipboard
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.localTime(formatter: DateTimeFormatter = ISO_LOCAL_TIME): BiDiLensSpec<IN, LocalTime>
fun Path.localTime(formatter: DateTimeFormatter = ISO_LOCAL_TIME): BiDiPathLensSpec<LocalTime>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun main()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T> Lens<Request, T>.matches(fn: (T) -> Boolean): Router

Check the content of any lens on a request for routing purposes.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@JvmName(name = "namedBiDi")
fun <IN : Any, OUT, L : BiDiLensBuilder<IN, OUT>> L.of(): DelegatedPropertyLensSpec<BiDiLens<IN, OUT>, OUT, BiDiLens<IN, OUT?>>
@JvmName(name = "namedBiDiList")
fun <IN : Any, OUT, L : BiDiLensBuilder<IN, List<OUT>>> L.of(): DelegatedPropertyLensSpec<BiDiLens<IN, List<OUT>>, List<OUT>, BiDiLens<IN, List<OUT>?>>
@JvmName(name = "named")
fun <IN : Any, OUT, L : LensBuilder<IN, OUT>> L.of(): DelegatedPropertyLensSpec<Lens<IN, OUT>, OUT, Lens<IN, OUT?>>
@JvmName(name = "namedList")
fun <IN : Any, OUT, L : LensBuilder<IN, List<OUT>>> L.of(): DelegatedPropertyLensSpec<Lens<IN, List<OUT>>, List<OUT>, Lens<IN, List<OUT>?>>
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.offsetDateTime(formatter: DateTimeFormatter = ISO_OFFSET_DATE_TIME): BiDiLensSpec<IN, OffsetDateTime>
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.offsetTime(formatter: DateTimeFormatter = ISO_OFFSET_TIME): BiDiLensSpec<IN, OffsetTime>
Link copied to clipboard
fun <IN : Any, VALUE : Value<T>, T : Any> Lens<IN, String>.ofOrLensFailure(vf: ValueFactory<VALUE, T>, value: String): VALUE

Convert ot throw a lens failure when constructing a value type

Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.regex(pattern: String, group: Int = 1): BiDiLensSpec<IN, String>
fun Path.regex(pattern: String, group: Int = 1): BiDiPathLensSpec<String>
fun Body.Companion.regex(pattern: String, group: Int = 1, contentType: ContentType = ContentType.TEXT_PLAIN, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<String>
Link copied to clipboard
fun Body.Companion.string(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<String>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <M : Any, VALUE : Value<T>, T : Any> BiDiLensSpec<M, String>.value(vf: ValueFactory<VALUE, T>): BiDiLensSpec<M, VALUE>

Custom lens for mapping to values4k Value

fun <VALUE : Value<T>, T : Any> BiDiPathLensSpec<String>.value(vf: ValueFactory<VALUE, T>): BiDiPathLensSpec<VALUE>

Custom lens for mapping Path to values4k Value

Link copied to clipboard

Convenience function to write the WebForm to the message body and set the content type.

fun Body.Companion.webForm(validator: Validator, vararg formFields: Lens<WebForm, *>): BiDiBodyLensSpec<WebForm>
fun Body.Companion.webForm(validator: Validator, contentNegotiation: ContentNegotiation, vararg formFields: Lens<WebForm, *>): BiDiBodyLensSpec<WebForm>
Link copied to clipboard
fun <IN : Any> BiDiLensSpec<IN, String>.zonedDateTime(formatter: DateTimeFormatter = ISO_ZONED_DATE_TIME): BiDiLensSpec<IN, ZonedDateTime>
fun Path.zonedDateTime(formatter: DateTimeFormatter = ISO_ZONED_DATE_TIME): BiDiPathLensSpec<ZonedDateTime>
Link copied to clipboard
Link copied to clipboard