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

Tower Service Trait implementation #659

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

omarabid
Copy link

This PR adds a Service struct that implements Tower Service Trait. This makes it possible to use crates that rely on this standard. The PR was only tested with Octocrab.

There is a minor change, too. Fetch::Request uses &self which leaves a dangling borrow. The PR changes this so that Fetch::Request consumes the original Fetch object. This should be harmless since Fetch is not returned anyway.

Example usage:

let service = worker::Service::default();

let octocrabi = octocrab::OctocrabBuilder::new_empty()
                .with_service(service)
                .with_layer(&BaseUriLayer::new(http::Uri::from_static(
                    "https://api.github.com",
                )))
                .with_layer(&ExtraHeadersLayer::new(Arc::new(vec![(
                    USER_AGENT,
                    "octocrab".parse().unwrap(),
                )])))
                .with_layer(&ExtraHeadersLayer::new(Arc::new(vec![(
                    "Authorization".parse().unwrap(),
                    "Bearer xxxxxxxxxxxxxxxxxxxxx"
                        .parse()
                        .unwrap(),
                )])))
                .with_auth(AuthState::None);

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

Successfully merging this pull request may close these issues.

1 participant