[][src]Crate rifling

Rifling

Rifling is a framework to create Github Webhook listener, influenced by afterparty.

Current version of rifling supports hyper 0.12 only.

It supports both application/json and application/x-www-form-urlencoded mode.

Minimal Example:

extern crate hyper;
extern crate rifling;

use rifling::{Constructor, Delivery, Hook};
use hyper::{Server, Error};
use hyper::rt::{run, Future};

fn main() {
    let mut cons = Constructor::new();
    let hook = Hook::new("*", Some(String::from("secret")), |delivery: &Delivery| println!("Received delivery: {:?}", delivery));
    cons.register(hook);
    let addr = "0.0.0.0:4567".parse().unwrap();
    let server = Server::bind(&addr).serve(cons).map_err(|e: Error| println!("Error: {:?}", e));
    run(server);
}

TODO in future versions:

  • Error handling.
  • Support other web frameworks (such as Tide).

Re-exports

pub use handler::Constructor;
pub use handler::ContentType;
pub use handler::Delivery;
pub use handler::DeliveryType;
pub use handler::Handler;
pub use hook::Hook;
pub use hook::HookFunc;

Modules

handler

Universal part between of different frameworks

hook

Hook

Macros

hooks_find_match

Find matched hooks from HookRegistry, accepting multiple keys.

unwrap_or_false

Unwrap Option<T> or return false