Sean Abbott
08/23/2021, 7:16 PMfun partnerAccountTaskRoute(): ContractRoute {
return spec to ::partnerAccountTaskHandler
}
fun partnerAccountTaskHandler(partnerAccountId: Long, task: String, taskType: String): HttpHandler = { request: Request ->
...
}
and
fun validTaskTypeFilter() = Filter { next ->
...
}
but I can't figure out how to compose the spec to ::function
with the filter on it"/" 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
// <https://stackoverflow.com/questions/61729113/how-to-expose-swagger-ui-with-http4k>
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.dave
08/23/2021, 7:44 PMSean Abbott
08/23/2021, 9:47 PMfun partnerAccountTaskHandler(
partnerAccountId: Long,
task: String,
taskType: String): HttpHandler = validTaskTypeFilter().then(){ request: Request ->
filteredPartnerAccountTaskHandler(partnerAccountId, taskType, request)
}