All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kweb.routing.RouteReceiver.kt Maven / Gradle / Ivy

There is a newer version: 1.4.12
Show newest version
package kweb.routing

import io.ktor.server.routing.RoutingPath
import kweb.h1

class RouteReceiver internal constructor() {
    internal val templatesByLength = HashMap>()

    internal var notFoundReceiver: NotFoundReceiver = { path ->
        h1().text("Not Found: $path")
    }

    fun path(template: String, pathReceiver: PathReceiver) {
        val routingPath = RoutingPath.parse(template).parts
        templatesByLength.computeIfAbsent(routingPath.size) { HashMap() }[routingPath] = pathReceiver
    }

    fun notFound(receiver: NotFoundReceiver) {
        notFoundReceiver = receiver
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy