api

http4k / org.http4k.filter

Package org.http4k.filter

This is the base package for all Filter implementations.

Types

Name Summary
AllowAllOriginPolicy object AllowAllOriginPolicy : OriginPolicy
CacheControlHeaderPart open class CacheControlHeaderPart
CachingFilters Useful filters for applying Cache-Controls to request/responsesobject CachingFilters
CanonicalPayload data class CanonicalPayload
ClientFilters object ClientFilters
CompressionResult data class CompressionResult
CorsPolicy data class CorsPolicy
DebuggingFilters object DebuggingFilters
DefaultCacheTimings data class DefaultCacheTimings
GzipCompressionMode sealed class GzipCompressionMode
HttpTransactionLabeler typealias HttpTransactionLabeler = (HttpTransaction) -> HttpTransaction
MaxAgeTtl data class MaxAgeTtl : CacheControlHeaderPart
MicrometerMetrics class MicrometerMetrics
OpenTelemetryMetrics class OpenTelemetryMetrics
OriginPolicy For creating custom origin policy for allowing CORSinterface OriginPolicy : (String) -> Boolean
Payload object Payload
RequestFilters object RequestFilters
ResilienceFilters object ResilienceFilters
ResponseFilters object ResponseFilters
SamplingDecision data class SamplingDecision
ServerFilters object ServerFilters
StaleIfErrorTtl data class StaleIfErrorTtl : CacheControlHeaderPart
StaleWhenRevalidateTtl data class StaleWhenRevalidateTtl : CacheControlHeaderPart
TraceId data class TraceId
TrafficFilters object TrafficFilters
ZipkinTraces data class ZipkinTraces

Extensions for External Classes

Name Summary
kotlin.Function1  

Properties

Name Summary
MicrometerMetrics val ClientFilters.MicrometerMetrics: MicrometerMetrics
val ServerFilters.MicrometerMetrics: MicrometerMetrics
OpenTelemetryMetrics val ClientFilters.OpenTelemetryMetrics: OpenTelemetryMetrics
val ServerFilters.OpenTelemetryMetrics: OpenTelemetryMetrics

Functions

Name Summary
Assert Perform an assertThat on the incoming Request as a Filter operationfun RequestFilters.Assert(matcher: Matcher<Request>): <ERROR CLASS>
Perform an assertThat on the outgoing Response as a Filter operationfun ResponseFilters.Assert(matcher: Matcher<Response>): <ERROR CLASS>
Perform an assertion on the incoming Request as a Filter operationfun RequestFilters.Assert(match: Matcher<HttpMessage>): <ERROR CLASS>
Perform an assertion on the outgoing Response as a Filter operationfun ResponseFilters.Assert(match: Matcher<HttpMessage>): <ERROR CLASS>
AwsAuth Sign AWS requests using static credentials.fun ClientFilters.AwsAuth(scope: AwsCredentialScope, credentials: AwsCredentials, clock: Clock = Clock.systemDefaultZone(), payloadMode: Mode = Payload.Mode.Signed): <ERROR CLASS>
Sign AWS requests using dynamically provided (expiring) credentials.fun ClientFilters.AwsAuth(scope: AwsCredentialScope, credentialsProvider: () -> AwsCredentials, clock: Clock = Clock.systemDefaultZone(), payloadMode: Mode = Payload.Mode.Signed): <ERROR CLASS>
gunzipped fun Body.gunzipped(): Body
gunzippedStream fun Body.gunzippedStream(): Body
gzipped fun Body.gzipped(): CompressionResult
gzippedStream fun Body.gzippedStream(): CompressionResult
HandleRemoteRequestFailed Handle exceptions from remote calls and convert them into sensible server-side errors. Optionally pass in a function to format the response body from the exception.fun ServerFilters.HandleRemoteRequestFailed(exceptionToBody: RemoteRequestFailed.() -> String = Throwable::getLocalizedMessage): Filter
Convert errors from remote calls into exceptions which can be handled at a higher level. Optionally pass in:fun ClientFilters.HandleRemoteRequestFailed(responseWasSuccessful: Response.() -> Boolean = { status.successful }, responseToMessage: Response.() -> String = Response::bodyString): <ERROR CLASS>
inIntelliJOnly fun Filter.inIntelliJOnly(): Filter
OpenTelemetryTracing fun ClientFilters.OpenTelemetryTracing(tracer: Tracer = Http4kOpenTelemetry.tracer, spanNamer: (Request) -> String = { it.uri.toString() }, error: (Request, Throwable) -> String = { _, t -> t.localizedMessage }): Filter
fun ServerFilters.OpenTelemetryTracing(tracer: Tracer = Http4kOpenTelemetry.tracer, spanNamer: (Request) -> String = { it.uri.toString() }, error: (Request, Throwable) -> String = { _, t -> t.localizedMessage }): Filter
ProcessFiles Process files on upload using the passed consumer, which returns a reference. The form file is replaced in the form with this reference.fun ServerFilters.ProcessFiles(fileConsumer: (File) -> String): <ERROR CLASS>
SetAwsServiceUrl fun ClientFilters.SetAwsServiceUrl(serviceName: String, region: String): Filter

Companion Object Functions

Name Summary
AllowAll Allows all origins for CORSfun OriginPolicy.Companion.AllowAll(): AllowAllOriginPolicy
AnyOf Allows a given list of origins for CORSfun OriginPolicy.Companion.AnyOf(allowedOrigins: List<String>): OriginPolicy
fun OriginPolicy.Companion.AnyOf(vararg allowedOrigins: String): OriginPolicy
Only Allows a given single origin for CORSfun OriginPolicy.Companion.Only(allowedOrigin: String): OriginPolicy
Pattern Allows origin(s) matching a Regex for CORSfun OriginPolicy.Companion.Pattern(originRegex: Regex): OriginPolicy