diff --git a/README.md b/README.md index cfa479b..99990d4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # tower-github-webhook `tower-github-webhook` is a crate that simplifies validating webhooks received from GitHub. + +[![Crates.io](https://img.shields.io/crates/v/tower-github-webhook)](https://crates.io/crates/tower-github-webhook) +[![Documentation](https://docs.rs/tower-github-webhook/badge.svg)](https://docs.rs/tower-github-webhook) +[![Crates.io](https://img.shields.io/crates/l/tower-github-webhook)](tower-github-webhook/LICENSE) diff --git a/src/layer.rs b/src/layer.rs index 4fe0bbb..77d8d72 100644 --- a/src/layer.rs +++ b/src/layer.rs @@ -1,12 +1,16 @@ use crate::ValidateGitHubWebhook; use tower::Layer; +/// Layer that applies the [ValidateGitHubWebhook] middleware which authorizes all requests using +/// the `X-Hub-Signature-256` header. #[derive(Clone)] pub struct ValidateGitHubWebhookLayer { webhook_secret: Secret, } impl ValidateGitHubWebhookLayer { + /// Authorize requests using the `X-Hub-Signature-256` header. If the signature specified in + /// that header is not signed using the `webhook_secret` secret, the request will fail. pub fn new(webhook_secret: Secret) -> Self { Self { webhook_secret } } diff --git a/src/service.rs b/src/service.rs index 02445c6..b67e7bf 100644 --- a/src/service.rs +++ b/src/service.rs @@ -6,6 +6,7 @@ use sha2::Sha256; use std::task::{Context, Poll}; use tower::Service; +/// Middleware that authorizes all requests using the X-Hub-Signature-256 header. #[derive(Clone)] pub struct ValidateGitHubWebhook { inner: S,