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

org.http4k.core.HttpTransaction.kt Maven / Gradle / Ivy

package org.http4k.core

import org.http4k.routing.RequestWithRoute
import org.http4k.routing.ResponseWithRoute
import java.time.Duration

data class HttpTransaction(
    val request: Request,
    val response: Response,
    val duration: Duration,
    val labels: Map = when {
        response is ResponseWithRoute -> mapOf(ROUTING_GROUP_LABEL to response.xUriTemplate.toString())
        request is RequestWithRoute -> mapOf(ROUTING_GROUP_LABEL to request.xUriTemplate.toString())
        else -> emptyMap()
    }
) {
    fun label(name: String, value: String) = copy(labels = labels + (name to value))
    fun label(name: String) = labels[name]

    val routingGroup = labels[ROUTING_GROUP_LABEL] ?: "UNMAPPED"

    companion object {
        internal const val ROUTING_GROUP_LABEL = "routingGroup"
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy