Using hashicorp go-retryablehttp library (https://github.com/hashicorp/go-retryablehttp)
It retries automatically for all 5xx code:
retryablehttp performs automatic retries under certain conditions. Mainly, if an error is returned by the client (connection errors, etc.), or if a 500-range response code is received (except 501), then a retry is invoked after a wait period. Otherwise, the response is returned and left to the caller to interpret.
Is that possible it retries on Request Timeout, e.g. on 408 http status code just ootb?
or I should build some custom wrappers?
You can implement your own retry policy and pass it to the Client.CheckRetry field.
Doc ref:
Code ref:
The code might look like something similar to