Skip to content

RequestInterceptor

[Source]

Synchronous request interceptor that runs before the handler is created.

Interceptors inspect the request and return InterceptPass to let it through or InterceptRespond to short-circuit with an HTTP response. The return type forces an explicit decision — the compiler won't accept an interceptor that forgets to decide.

Interceptors are val and must be stateless or capture only immutable configuration. They run synchronously in the connection actor, so they should do only cheap work (header checks, size limits). Expensive or async work belongs in the handler.

interface val RequestInterceptor

Public Functions

apply

[Source]

Evaluate the request. Return InterceptPass to continue to the handler, or InterceptRespond to short-circuit with a response.

fun box apply(
  request: Request box)
: (InterceptPass val | InterceptRespond ref)

Parameters

Returns