#axum #github-webhook #github #token #action #github-event

axum-github-webhook-extract

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

5 unstable releases

0.3.0 Mar 5, 2025
0.2.0 Dec 11, 2023
0.1.2 Jun 10, 2023
0.1.1 Jun 10, 2023
0.1.0 Jun 10, 2023

#429 in HTTP server

Download history 150/week @ 2025-03-04 7/week @ 2025-03-11 7/week @ 2025-03-18 122/week @ 2025-03-25 33/week @ 2025-04-01

171 downloads per month

MIT license

10KB
133 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