localPort

fun Route.localPort(port: Int, build: Route.() -> Unit): Route

Create a route to match the port on which the call was received.

The selector checks the io.ktor.request.ApplicationRequest.local request port, ignoring HTTP headers such as "Host" or "X-Forwarded-Host". This is useful for securing routes under separate ports.

For multi-tenant applications, you may want to use io.ktor.routing.port, which takes HTTP headers into consideration.

Parameters

port

the port to match against

Throws

if the port is outside the range of TCP/UDP ports