com.hexagonkt.http.handlers.AfterHandler.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http_handlers Show documentation
Show all versions of http_handlers Show documentation
HTTP handlers used to apply many callbacks to HTTP calls.
package com.hexagonkt.http.handlers
import com.hexagonkt.handlers.AfterHandler
import com.hexagonkt.handlers.Handler
import com.hexagonkt.http.model.HttpMethod
import com.hexagonkt.http.model.HttpStatus
import com.hexagonkt.http.model.HttpCall
import kotlin.reflect.KClass
data class AfterHandler(
override val handlerPredicate: HttpPredicate = HttpPredicate(),
val block: HttpCallbackType
) : HttpHandler, Handler by AfterHandler(handlerPredicate, toCallback(block)) {
constructor(
methods: Set = emptySet(),
pattern: String = "",
exception: KClass? = null,
status: HttpStatus? = null,
block: HttpCallbackType,
) :
this(HttpPredicate(methods, pattern, exception, status), block)
constructor(method: HttpMethod, pattern: String = "", block: HttpCallbackType) :
this(setOf(method), pattern, block = block)
constructor(pattern: String, block: HttpCallbackType) :
this(emptySet(), pattern, block = block)
override fun addPrefix(prefix: String): HttpHandler =
copy(handlerPredicate = handlerPredicate.addPrefix(prefix))
}