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

dev.pellet.server.routing.http.PelletHTTPRouter.kt Maven / Gradle / Ivy

There is a newer version: 0.0.16
Show newest version
package dev.pellet.server.routing.http

import dev.pellet.server.codec.http.HTTPRequestMessage

class PelletHTTPRouter : HTTPRouting {

    override val routes = mutableListOf()

    override fun add(route: PelletHTTPRoute) {
        routes.add(route)
    }

    override fun route(
        message: HTTPRequestMessage
    ): PelletHTTPRoute? {
        // todo: investigate if route matching can be better than O(n)
        return routes.firstOrNull {
            it.method == message.requestLine.method && message.requestLine.resourceUri == it.uri
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy