api

http4k / org.http4k.lens

Package org.http4k.lens

Code relevant to extracting and injecting typesafe values into HTTP messages.

Types

Name Summary
BiDiBodyLens class BiDiBodyLens<FINAL> : LensInjector<FINAL, HttpMessage>, BodyLens<FINAL>
A BiDiBodyLens provides the bi-directional extraction of an entity from a target body, or the insertion of an entity into a target body.
BiDiBodyLensSpec open class BiDiBodyLensSpec<OUT> : BodyLensSpec<OUT>
Represents a bi-directional extraction of an entity from a target Body, or an insertion into a target Body.
BiDiLens class BiDiLens<in IN : Any, FINAL> : LensInjector<FINAL, IN>, Lens<IN, FINAL>
A BiDiLens provides the bi-directional extraction of an entity from a target, or the insertion of an entity into a target.
BiDiLensSpec open class BiDiLensSpec<IN : Any, OUT> : LensSpec<IN, OUT>
Represents a bi-directional extraction of an entity from a target, or an insertion into a target.
BiDiMapping class BiDiMapping<IN, OUT>
A BiDiMapping defines a reusable bidirectional transformation between an input and output type
BiDiMultiLensSpec interface BiDiMultiLensSpec<IN : Any, OUT> : MultiLensSpec<IN, OUT>
Represents a bi-directional extraction of a list of entities from a target, or an insertion into a target.
BiDiPathLens class BiDiPathLens<FINAL> : LensInjector<FINAL, Request>, PathLens<FINAL>
BiDiPathLensSpec open class BiDiPathLensSpec<OUT> : PathLensSpec<OUT>
BiDiWsMessageLens class BiDiWsMessageLens<FINAL> : WsMessageLens<FINAL>
A BiDiWsMessageLens provides the bi-directional extraction of an entity from a target body, or the insertion of an entity into a target WsMessage.
BiDiWsMessageLensSpec open class BiDiWsMessageLensSpec<OUT> : WsMessageLensSpec<OUT>
Represents a bi-directional extraction of an entity from a target Body, or an insertion into a target WsMessage.
BodyLens open class BodyLens<out FINAL> : LensExtractor<HttpMessage, FINAL>
A BodyLens provides the uni-directional extraction of an entity from a target body.
BodyLensSpec open class BodyLensSpec<out OUT>
Represents a uni-directional extraction of an entity from a target Body.
ContentNegotiation interface ContentNegotiation
Modes for determining if a passed content type is acceptable.
Cookies object Cookies : BiDiLensSpec<Request, Cookie>
Failure sealed class Failure
FormField object FormField : BiDiLensSpec<WebForm, String>
Header object Header : BiDiLensSpec<HttpMessage, String>
Invalid data class Invalid : Failure
Lens open class Lens<in IN : Any, out FINAL> : LensExtractor<IN, FINAL>, Iterable<Meta>
A Lens provides the uni-directional extraction of an entity from a target.
LensExtractor interface LensExtractor<in IN, out OUT> : (IN) -> OUT
LensGet class LensGet<in IN, out OUT>
LensInjector interface LensInjector<in IN, in OUT>
LensSet class LensSet<IN, in OUT>
LensSpec open class LensSpec<IN : Any, OUT>
Represents a uni-directional extraction of an entity from a target.
Meta data class Meta
Missing data class Missing : Failure
MultiLensSpec interface MultiLensSpec<IN : Any, OUT>
Represents a uni-directional extraction of a list of entities from a target.
MultipartForm data class MultipartForm : Closeable
MultipartFormField object MultipartFormField : BiDiLensSpec<MultipartForm, String>
MultipartFormFile object MultipartFormFile : BiDiLensSpec<MultipartForm, FormFile>
ParamMeta enum class ParamMeta
Path object Path : BiDiPathLensSpec<String>
PathLens open class PathLens<out FINAL> : Lens<Request, FINAL>
PathLensSpec open class PathLensSpec<out OUT>
Represents a uni-directional extraction of an entity from a target path segment.
Query object Query : BiDiLensSpec<Request, String>
RequestContextKey object RequestContextKey
StringBiDiMappings object StringBiDiMappings
A set of standardised String <-> Type conversions which are used throughout http4k
Unsupported data class Unsupported : Failure
Validator enum class Validator
Runs through a list of lenses and extracts the values from each one, collecting the errors
WebForm data class WebForm
WsMessageLens open class WsMessageLens<out FINAL> : LensExtractor<WsMessage, FINAL>
A WsMessageLens provides the extraction of an entity from a target WsMessage.
WsMessageLensSpec open class WsMessageLensSpec<out OUT>
Represents a extraction of an entity from a target WsMessage.

Exceptions

Name Summary
LensFailure class LensFailure : Exception

Type Aliases

Name Summary
HeaderLens typealias HeaderLens<T> = Lens<HttpMessage, T>
QueryLens typealias QueryLens<T> = Lens<Request, T>
RequestContextLens typealias RequestContextLens<T> = BiDiLens<Request, T>

Properties

Name Summary
HOST val Header.HOST: BiDiLens<HttpMessage, Authority?>
MULTIPART_BOUNDARY val MULTIPART_BOUNDARY: String

Functions

Name Summary
authority fun StringBiDiMappings.authority(): BiDiMapping<String, Authority>
fun <IN : Any> BiDiLensSpec<IN, String>.authority(): BiDiLensSpec<IN, Authority>
bigDecimal fun <IN : Any> BiDiLensSpec<IN, String>.bigDecimal(): BiDiLensSpec<IN, BigDecimal>
fun Path.bigDecimal(): BiDiPathLensSpec<BigDecimal>
bigInteger fun <IN : Any> BiDiLensSpec<IN, String>.bigInteger(): BiDiLensSpec<IN, BigInteger>
fun Path.bigInteger(): BiDiPathLensSpec<BigInteger>
boolean fun <IN : Any> BiDiLensSpec<IN, String>.boolean(): BiDiLensSpec<IN, Boolean>
fun Path.boolean(): BiDiPathLensSpec<Boolean>
bytes fun <IN : Any> BiDiLensSpec<IN, String>.bytes(): LensSpec<IN, ByteArray>
dateTime 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>
double fun <IN : Any> BiDiLensSpec<IN, String>.double(): BiDiLensSpec<IN, Double>
fun Path.double(): BiDiPathLensSpec<Double>
duration fun <IN : Any> BiDiLensSpec<IN, String>.duration(): BiDiLensSpec<IN, Duration>
fun Path.duration(): BiDiPathLensSpec<Duration>
float fun <IN : Any> BiDiLensSpec<IN, String>.float(): BiDiLensSpec<IN, Float>
fun Path.float(): BiDiPathLensSpec<Float>
host fun StringBiDiMappings.host(): BiDiMapping<String, Host>
fun <IN : Any> BiDiLensSpec<IN, String>.host(): BiDiLensSpec<IN, Host>
httpBodyRoot fun httpBodyRoot(metas: List<Meta>, acceptedContentType: ContentType, contentNegotiation: ContentNegotiation): BiDiBodyLensSpec<Body>
instant fun <IN : Any> BiDiLensSpec<IN, String>.instant(): BiDiLensSpec<IN, Instant>
fun Path.instant(): BiDiPathLensSpec<Instant>
int fun <IN : Any> BiDiLensSpec<IN, String>.int(): BiDiLensSpec<IN, Int>
fun Path.int(): BiDiPathLensSpec<Int>
localDate 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>
localTime 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>
long fun <IN : Any> BiDiLensSpec<IN, String>.long(): BiDiLensSpec<IN, Long>
fun Path.long(): BiDiPathLensSpec<Long>
map fun <NEXT, IN : Any, OUT> BiDiLensSpec<IN, OUT>.map(mapping: BiDiMapping<OUT, NEXT>): BiDiLensSpec<IN, NEXT>
nonEmptyString fun <IN : Any> BiDiLensSpec<IN, String>.nonEmptyString(): BiDiLensSpec<IN, String>
fun Path.nonEmptyString(): BiDiPathLensSpec<String>
offsetDateTime fun <IN : Any> BiDiLensSpec<IN, String>.offsetDateTime(formatter: DateTimeFormatter = ISO_OFFSET_DATE_TIME): BiDiLensSpec<IN, OffsetDateTime>
offsetTime fun <IN : Any> BiDiLensSpec<IN, String>.offsetTime(formatter: DateTimeFormatter = ISO_OFFSET_TIME): BiDiLensSpec<IN, OffsetTime>
port fun StringBiDiMappings.port(): BiDiMapping<String, Port>
fun <IN : Any> BiDiLensSpec<IN, String>.port(): BiDiLensSpec<IN, Port>
regex 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>
regexObject fun <IN : Any> BiDiLensSpec<IN, String>.regexObject(): BiDiLensSpec<IN, Regex>
fun Path.regexObject(): BiDiPathLensSpec<Regex>
secret fun <IN : Any> BiDiLensSpec<IN, String>.secret(): LensSpec<IN, Secret>
string fun <IN : Any> BiDiLensSpec<IN, String>.string(): BiDiLensSpec<IN, String>
fun Path.string(): Path
timeout fun <IN : Any> BiDiLensSpec<IN, String>.timeout(): BiDiLensSpec<IN, Timeout>
uri fun <IN : Any> BiDiLensSpec<IN, String>.uri(): BiDiLensSpec<IN, Uri>
fun Path.uri(): BiDiPathLensSpec<Uri>
uuid fun <IN : Any> BiDiLensSpec<IN, String>.uuid(): BiDiLensSpec<IN, UUID>
fun Path.uuid(): BiDiPathLensSpec<UUID>
zonedDateTime 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>

Companion Object Functions

Name Summary
binary fun Body.Companion.binary(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<Body>
fun WsMessage.Companion.binary(): BiDiWsMessageLensSpec<ByteBuffer>
multipartForm fun Body.Companion.multipartForm(validator: Validator, vararg parts: Lens<MultipartForm, *>, defaultBoundary: String = MULTIPART_BOUNDARY, diskThreshold: Int = MultipartFormBody.DEFAULT_DISK_THRESHOLD): BiDiBodyLensSpec<MultipartForm>
nonEmptyString fun Body.Companion.nonEmptyString(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<String>
regex fun Body.Companion.regex(pattern: String, group: Int = 1, contentType: ContentType = ContentType.TEXT_PLAIN, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<String>
string fun Body.Companion.string(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<String>
fun WsMessage.Companion.string(): BiDiWsMessageLensSpec<String>
webForm fun Body.Companion.webForm(validator: Validator, vararg formFields: Lens<WebForm, *>): BiDiBodyLensSpec<WebForm>