WebRouter

class WebRouter(val basePath: String)

A router for managing the routing of HTTP requests with various methods (GET, POST, PUT, DELETE, etc.).

Constructors

Link copied to clipboard
constructor(basePath: String)

Properties

Link copied to clipboard

The base path for all routes defined within this router.

Functions

Link copied to clipboard
suspend fun applyMiddlewares(call: ApplicationCall, iterator: Iterator<WebMiddleware>, path: String, final: suspend () -> Unit)

Applies middleware in a sequential manner and invokes the final handler.

Link copied to clipboard
fun delete(path: String, builder: WebRouteBuilder.() -> Unit)

Defines a DELETE route.

Link copied to clipboard
fun get(path: String, builder: WebRouteBuilder.() -> Unit)

Defines a GET route.

Link copied to clipboard
fun head(path: String, builder: WebRouteBuilder.() -> Unit)

Defines a HEAD route.

Link copied to clipboard
fun installInto(app: Application)

Installs the router's routes and middlewares into a Ktor application.

Link copied to clipboard
fun options(path: String, builder: WebRouteBuilder.() -> Unit)

Defines an OPTIONS route.

Link copied to clipboard
fun patch(path: String, builder: WebRouteBuilder.() -> Unit)

Defines a PATCH route.

Link copied to clipboard
fun post(path: String, builder: WebRouteBuilder.() -> Unit)

Defines a POST route.

Link copied to clipboard
fun put(path: String, builder: WebRouteBuilder.() -> Unit)

Defines a PUT route.

Link copied to clipboard
fun use(middleware: WebMiddleware): Boolean

Adds middleware to be applied globally across all routes.