pl.allegro.tech.servicemesh.envoycontrol.config.envoy.HttpResponseCloser.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-tests Show documentation
Show all versions of envoy-control-tests Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
package pl.allegro.tech.servicemesh.envoycontrol.config.envoy
import okhttp3.Response
object HttpResponseCloser {
private val responses = mutableListOf()
fun closeResponses() {
responses.forEach(this::closeResponse)
responses.clear()
}
private fun closeResponse(response: Response) {
runCatching { response.close() }
}
fun Response.addToCloseableResponses() : Response {
responses.add(this)
return this
}
}