localPort

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

Creates a route to match a port on which a call was received.

The selector checks the io.ktor.server.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.server.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