api

http4k / org.http4k.routing / RoutingHttpHandler

RoutingHttpHandler

interface RoutingHttpHandler : Router, HttpHandler (source)

Composite HttpHandler which can potentially service many different URL patterns. Should return a 404 Response if it cannot service a particular Request.

Note that generally there should be no reason for the API user to implement this interface over and above the implementations that already exist. The interface is public only because we have not found a way to hide it from the API user in an API-consistent manner.

Functions

Name Summary
withBasePath abstract fun withBasePath(new: String): RoutingHttpHandler
Returns a RoutingHttpHandler which prepends the passed base path to the logic determining the match() To follow the trend of immutability, this will generally be a new instance.
withFilter abstract fun withFilter(new: Filter): RoutingHttpHandler
Returns a RoutingHttpHandler which applies the passed Filter to all received requests before servicing them. To follow the trend of immutability, this will generally be a new instance.

Inherited Functions

Name Summary
match abstract fun match(request: Request): HttpHandler?
Attempt to supply an HttpHandler which can service the passed request.

Extension Functions

Name Summary
asK8sServer fun HttpHandler.asK8sServer(serverConfig: (port: Int) -> ServerConfig, port: Int = 8000, healthApp: HttpHandler = Health(), healthPort: Int = 8001): Http4kK8sServer
fun HttpHandler.asK8sServer(serverConfig: (port: Int) -> ServerConfig, env: Environment = ENV, healthApp: HttpHandler = Health()): Http4kK8sServer
asServer fun HttpHandler.asServer(fn: (Int) -> ServerConfig, port: Port): Http4kServer
fun HttpHandler.asServer(config: ServerConfig): Http4kServer
asServlet fun HttpHandler.asServlet(): HttpHandlerServlet
with fun <T> T.with(vararg modifiers: (T) -> T): T
withAsyncApi fun HttpHandler.withAsyncApi(): AsyncHttpClient
Convert a synchronous HttpHandler API to mimic AsyncHttpClient
withChaosControls fun RoutingHttpHandler.~~withChaosControls~~(stage: Stage = ChaosStages.Wait, security: Security = NoSecurity, controlsPath: String = "/chaos", openApiPath: String = "", corsPolicy: CorsPolicy = CorsPolicy.UnsafeGlobalPermissive): RoutingHttpHandler
withChaosEngine fun RoutingHttpHandler.withChaosEngine(stage: Stage = Wait, security: Security = NoSecurity, controlsPath: String = "/chaos", openApiPath: String = "", corsPolicy: CorsPolicy = UnsafeGlobalPermissive): RoutingHttpHandler
Convert a standard HttpHandler to be Chaos-enabled, using the passed ChaosStage. Optionally a Security can be passed to limit access to the chaos controls.

Inheritors

Name Summary
ContractRoutingHttpHandler data class ContractRoutingHttpHandler : RoutingHttpHandler