Skip to content

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