How do you configure timeout for http4k client?
# http4k
m
How do you configure timeout for http4k client?
d
You can do this on the client level by configuration of the underlying http.lib client injected into the http4t client constructor
m
So something like?
Copy code
val httpClient: AsyncHttpHandler = ApacheAsyncClient(HttpAsyncClients.custom()
                .setDefaultRequestConfig(RequestConfig.custom()
                        .setRedirectsEnabled(false)
                        .setCookieSpec(StandardCookieSpec.IGNORE)
                        .setConnectTimeout(myConnectTimeoutGoesHere)
                        .setResponseTimeout(myResponseTimeoutGoesHere)
                        .build()).build().apply { start() })
Is this documented? Maybe it should be mentioned in some documentation or FAQ?
m
I don't see any mentions of timeout there.
d
we made a deliberate decision to not document the features of the configuring the libraries underlying http4k. They don't pay us enough for that kind of thing 🙂
m
Right, but maybe just mention that timeouts are configured in the underlying http libraries, without going into details how?
d
"Additionally, all HTTP client adapter modules allow for custom configuration of the relevant underlying client." 🙂
395 Views