<@U8RMYTB5L> Here's an example of how to combine l...
# http4k
s
@David Hamilton Here's an example of how to combine list of filters in a functional fashion:
Copy code
val defaultStack = Filter.NoOp.then(ClientFilters.GZip())

    val additionalFilters: List<Filter> = listOf(
        DebuggingFilters.PrintRequestAndResponse(),
        ClientFilters.BasicAuth("user", "pass"))

    // additional after default
    val combinedFilter1: Filter = additionalFilters.fold(defaultStack) { acc, next -> acc.then(next) }
    
    // additional before default
    val combinedFilter2: Filter = additionalFilters.fold(Filter.NoOp) { acc, next -> acc.then(next) }.then(defaultStack)
d
You even answered the unspoken question of whether the filters should be added before or after the existing stack
s
They can be added in either order. It depends on how your default stack is supposed to be used by each service really