<@U7R6RJRHN> I've been doing some thinking (you ca...
# http4k
d
@andyD I've been doing some thinking (you can hear the cogs grinding!) and I've come up with this:
Copy code
object TemplatedResponses {
        operator fun invoke(loader: ResourceLoader,
                            toResourceName: (Status) -> String? = { if (it.successful) null else it.code.toString() }): Filter = Filter { next ->
            {
                val response = next(it)
                toResourceName(response.status)
                    ?.let {
                    response.body(loader.load(it)?.readText() ?: "")
                } ?: response
            }
        }
    }