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

com.hexagonkt.http.patterns.PathPattern.kt Maven / Gradle / Ivy

Go to download

HTTP classes. These classes are shared among the HTTP client and the HTTP server.

The newest version!
package com.hexagonkt.http.patterns

interface PathPattern {

    val pattern: String
    val prefix: Boolean

    fun addPrefix(prefix: String?): PathPattern

    fun matches(requestUrl: String): Boolean

    fun extractParameters(requestUrl: String): Map

    fun insertParameters(parameters: Map): String =
        error("${type()} path pattern does not accept parameters")

    fun describe(): String =
        "${type()}${if (prefix) " (PREFIX)" else ""} '$pattern'"

    private fun type(): String =
        javaClass.simpleName.removeSuffix(typeSuffix)

    private companion object {
        val typeSuffix: String = PathPattern::class.java.simpleName
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy