Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support adding behaviour to the HTTP client using middlewares. #134

Open
LukeMathWalker opened this issue Oct 26, 2021 · 2 comments
Open

Comments

@LukeMathWalker
Copy link
Contributor

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.

@XAMPPRocky
Copy link
Owner

XAMPPRocky commented Oct 26, 2021

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.

@LukeMathWalker
Copy link
Contributor Author

That's a good strategy - I'll have a go at it this week/the next 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants