octocrab
octocrab copied to clipboard
Support adding behaviour to the HTTP client using middlewares.
An issue we have immediately run into is retries and tracing:
- we'd like to set a global retry policy when building the GitHub client;
- we'd like to have OpenTelemetry-compliant log fields for every request fired at GitHub.
Considering that octocrab is using reqwest as its HTTP client, would you be interested in adding support for client middlewares using reqwest-middleware?
We'd be happy to open a PR in this direction.
Thank you for your issue! I definitely want provide this customisability to users, however I do not want to use more reqwest specific libraries, I'd rather go in the opposite direction of removing reqwest entirely, and making Octocrab HTTP client agnostic (see #99). This would allow you to customise the client however you want.
If you'd be interested in working on that it's fairly straightforward task of replacing reqwest::Client in Octocrab with tower::BoxService<http::Request<hyper::Body>, http::Response<hyper::Body>> and updating any methods that break. Most methods call Octocrab's HTTP API so you should mostly only need to update the definitions in get, _get, post, _post, etc.
Feel free to ask questions if you get stuck.
That's a good strategy - I'll have a go at it this week/the next 😄