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

Matt

08/13/2021, 8:41 AM
Hello all, is it possible to stack filters which apply to specific routes? For example, could I have a stack of BasicAuth filters, each for a specific route?
d

dave

08/13/2021, 8:44 AM
it's purely function composition, so you can technically do whatever you want. 😉 . There are several options really - you can apply filters individually to each HttpHandler before putting them into the routes block, or just group the routes by which security you want to apply and then compose them. Or you could write a filter which applied another filter depending on the path.
Personally, I'd lean towards the first option (applying the correct filter to the correct route) as it's more explicit
m

Matt

08/13/2021, 9:04 AM
Thanks @dave
6 Views