afterparty
Where your commits go after github
Afterparty is a library for building Github webhook integrations in Rust.
docs
Find them here
install
Add the following to your Cargo.toml
file
[]
= "0.1"
usage
Afterparty has two key abstractions, a Hook
: a handler interface webhook deliveries, and a Hub
: a registry for hooks. A Hub
provides Delivery
instances to interested hooks.
A Delivery
encodes all relevant webhook request information including a unique identifier for the delivery, the event name, and statically typed payload represented as an enumerated type of Event
.
Hooks subscribe to Events via Hub
's a handle
and handle_authenticated
functions.
To subscribe to multiple events, subscribe with "*" and pattern match on the provided delivery's payload value.
To register your webhook with Github visit your repo's hooks configuration form https://github.com/{login}/{repo}/settings/hooks/new
and select the events you
want Github to notify your server about.
Hubs implements Hyper's Server Handler trait so that it may be mounted into any hyper Server.
extern crate afterparty;
extern crate hyper;
use Server;
use ;
note on UFCS
In the case that you have hyper::server::Handler and hubcaps::Hub in scope you may need to use UFCS to invoke the handle method on a HUB instance.
For example...
extern crate afterparty;
extern crate hyper;
use Handle;
use ;
building
As far as rust project builds go this one is somewhat interesting. This library uses serde for json encoding/decoding
and is focused on stable rust releases so a tactic for code generatation at build time is employed. Before that happens
an attempt is made to synthesize structs based on Github api documentation json vendored in the data directory.
A known issue exists where the repo deployments_url
field is omitted with a fresh set of json. serde will error at
deserializing because of this. This field was hand added within the json vendored dataset for the time being. Serde 0.7
will likely be released soon and will enable this library to avoid these kinds of runtime deserialization errors for
missing fields.
Doug Tangren (softprops) 2015-2016