https://kotlinlang.org logo
#http4k
Title
# http4k
m

Matt

05/10/2022, 10:52 AM
Hello all, in the
greetRoute()
example (https://www.http4k.org/guide/reference/contracts/), how would I apply a filter before the
greet(nameFromPath: String)
handler is invoked?
d

dave

05/10/2022, 11:15 AM
you have options. at the lowest level, you can :
Copy code
fun greet(nameFromPath: String): HttpHandler = filter.then { request: Request ->
        val age = ageQuery(request)
        val sentMessage = stringBody(request)

        Response(OK).with(stringBody of "hello $nameFromPath you are $age. You sent $sentMessage")
    } @
m

Matt

05/10/2022, 11:20 AM
Thanks @dave