Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRollen committed Jan 28, 2024
1 parent a34d89f commit 9c7bb49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions src/layer.rs
Original file line number Diff line number Diff line change
@@ -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<Secret> {
webhook_secret: Secret,
}

impl<Secret> ValidateGitHubWebhookLayer<Secret> {
/// 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 }
}
Expand Down
1 change: 1 addition & 0 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S> {
inner: S,
Expand Down

0 comments on commit 9c7bb49

Please sign in to comment.