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

com.hexagonkt.http.handlers.AfterHandler.kt Maven / Gradle / Ivy

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))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy