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

Extending Building a middleware from scratch guide #751

Closed
samueljoli opened this issue Nov 5, 2023 · 0 comments
Closed

Extending Building a middleware from scratch guide #751

samueljoli opened this issue Nov 5, 2023 · 0 comments

Comments

@samueljoli
Copy link

samueljoli commented Nov 5, 2023

The Building a middleware from scratch is a great guide, I think it would be an improvement if the following steps were added:

  • Creating a layer
impl TimeoutLayer {
    /// Create a timeout from a duration
    pub fn new(timeout: Duration) -> Self {
        TimeoutLayer { timeout }
    }
}

impl<S> Layer<S> for TimeoutLayer {
    type Service = Timeout<S>;

    fn layer(&self, service: S) -> Self::Service {
        Timeout::new(service, self.timeout)
    }
}
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

1 participant