<@U22BBEZQU> The filters are just functions which ...
# http4k
d
@jdiaz The filters are just functions which are composed together, modifying the request as it flows through the stack. as for the Labeller, there currently isn't really any specific documentation, but it's all pretty simple under the hood once you understand Filters - the HttpTransaction is just created with the Request, Response and the duration. here's the entire thing:
Copy code
object ReportHttpTransaction {
        operator fun invoke(clock: Clock = Clock.systemUTC(), transactionLabeller: HttpTransactionLabeller = { it }, recordFn: (HttpTransaction) -> Unit): Filter = Filter { next ->
            {
                clock.instant().let { start ->
                    next(it).apply {
                        recordFn(transactionLabeller(HttpTransaction(it, this, between(start, clock.instant()))))
                    }
                }
            }
        }
    }
. As for the actual problem that you're experiencing, here's an example which would do what you want...
Copy code
import org.http4k.core.Filter
import org.http4k.core.Method.GET
import <http://org.http4k.core.Method.POST|org.http4k.core.Method.POST>
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.core.then
import org.http4k.filter.ResponseFilters.ReportHttpTransaction
import org.http4k.routing.bind
import org.http4k.routing.routes

fun main(args: Array<String>) {

    fun named(name: String): Filter = ReportHttpTransaction(
        transactionLabeller = { it.label("routename", name) }) {
        println("metrics get done here for ... " + it.labels)
    }

    val app = routes(
        "/" bind GET to named("get route").then { _: Request -> Response(OK).body("get") },
        "/" bind POST to named("post route").then { _: Request -> Response(OK).body("get") }
    )

    println(app(Request(GET, "/")))
    println(app(Request(POST, "/")))
}