#github #github-webhook

axum-github-webhook-extract

A library to secure GitHub Webhooks and extract JSON event payloads in Axum

4 releases

0.2.0 Dec 11, 2023
0.1.2 Jun 10, 2023
0.1.1 Jun 10, 2023
0.1.0 Jun 10, 2023

#11 in #github-webhook

Download history 2/week @ 2024-09-07 26/week @ 2024-09-14 26/week @ 2024-09-21 11/week @ 2024-09-28 5/week @ 2024-10-05

69 downloads per month

MIT license

10KB
128 lines

axum-github-webhook-extract

Build Crates.io Documentation

A library to secure GitHub Webhooks and extract JSON event payloads in Axum. See documentation for how to use the library.


lib.rs:

A library to secure GitHub Webhooks and extract JSON event payloads in Axum.

The library is an Extractor paired with State to provide the required Secret Token.

Usage looks like:

use axum_github_webhook_extract::{GithubToken, GithubEvent};

#[derive(Debug, Deserialize)]
struct Event {
    action: String,
}

async fn echo(GithubEvent(e): GithubEvent<Event>) -> impl IntoResponse {
    e.action
}

fn app() -> Router {
    let token = String::from("d4705034dd0777ee9e1e3078a12a06985151b76f");
    Router::new()
        .route("/", post(echo))
        .with_state(GithubToken(Arc::new(token)))
}

You will usually get the token from your environment or configuration. The event payload is under your control, just make sure to configure it to use JSON.

Dependencies

~5–12MB
~137K SLoC