[][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); // Start the server, commented out because it will cause `cargo test` to hang.
}

TODO in future versions:

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

Re-exports

pub use constructor::Constructor;
pub use handler::Delivery;
pub use hook::Hook;

Modules

constructor

Constructor of the service

handler

The handler of requests

hook

Hook

Macros

hooks_find_match

Find matched hooks from HookRegistry, accepting multiple keys.