Function warp_github_webhook::webhook
source · [−]pub fn webhook<T>(
Kind: Kind,
secret: impl AsRef<str> + Clone + Send + Sync + 'static
) -> impl Clone + Debug + Filter<Extract = (T,), Error = Rejection> where
T: 'static + DeserializeOwned + Send,
Expand description
Creates a GitHub webhook responder.
The generic T
parameter points to a deserializable structure. This
crate doesn’t provide its own structures, you are intended to write down
your own. The reason for that is that this allows skipping parsing
unnecessary data.
Examples
use serde_derive::Deserialize;
use warp::{path, Filter};
use warp_github_webhook::{webhook, Kind};
#[derive(Deserialize)]
struct PushEvent {
compare: String,
}
let route = path!("github")
.and(webhook(Kind::PUSH, ""))
.map(|PushEvent { compare }| compare);