So a few days ago, you said you'd suggest applying...
# http4k
So a few days ago, you said you'd suggest applying the correct filter to the correct route. Is that possible with a ContractRoute? I have
Copy code
fun partnerAccountTaskRoute(): ContractRoute {
    return spec to ::partnerAccountTaskHandler
fun partnerAccountTaskHandler(partnerAccountId: Long, task: String, taskType: String): HttpHandler = { request: Request ->
fun validTaskTypeFilter() = Filter { next ->
but I can't figure out how to compose the
spec to ::function
with the filter on it
I suppose I should expend that al the contract routes are getting added like
Copy code
"/" bind contract {
        renderer = OpenApi3(ApiInfo("Thing API", "v1.0"), Jackson)

        // Return Swagger API definition under /swagger.json
        // This does not include the swagger UI, but apparently we could add it
        // <>
        descriptionPath = "/swagger.json"

        // Add contract routes
        routes += ExampleContractRoute()
        routes += HealthRoute()
        routes += partnerAccountRoute()
        routes += partnerAccountTaskRoute()
but right now I only want to put the filter on that last one; it's got a dynamic endpoing and I'd like to validate that endpoint with the filter, rather than as part of the handler.
The bound route function returns an HttpHandler a you just need to.ensure the filter wraps that handler when it's "created"
Not sure if htis is ideal, but this works (in case other new folks happen to be lurking and curious)
Copy code
fun partnerAccountTaskHandler(
    partnerAccountId: Long,
    task: String,
    taskType: String): HttpHandler = validTaskTypeFilter().then(){ request: Request ->
        filteredPartnerAccountTaskHandler(partnerAccountId, taskType, request)
(task is a static placeholder in the route, so it's not actually necessary to pass it into the function where the work happens)
Thank you again for the pointer! Took me awhile to grok the function composition element of this.