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

io.javalin.core.util.MethodNotAllowedUtil.kt Maven / Gradle / Ivy

The newest version!
package io.javalin.core.util

import io.javalin.Context
import io.javalin.core.HandlerType
import io.javalin.core.PathMatcher

object MethodNotAllowedUtil {

    fun findAvailableHttpHandlerTypes(matcher: PathMatcher, requestUri: String) =
            enumValues().filter { it.isHttpMethod() && matcher.findEntries(it, requestUri).isNotEmpty() }

    fun getAvailableHandlerTypes(ctx: Context, availableHandlerTypes: List): Map = mapOf(
            (if (ContextUtil.acceptsHtml(ctx)) "Available methods" else "availableMethods") to availableHandlerTypes.joinToString(", ")
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy