softprops / afterparty

rust github webhook server
MIT License
55 stars 13 forks source link

example can not run #17

Closed ggaaooppeenngg closed 7 years ago

ggaaooppeenngg commented 7 years ago

I just run the example and get a error

fn main() {
    let mut hub = Hub::new();
    hub.handle("*", |delivery: &Delivery| {
        println!("rec delivery {:#?}", delivery)
    });
    hub.handle_authenticated("pull_request", "secret", |delivery: &Delivery| {
       println!("rec authenticated delivery");
       match delivery.payload {
           Event::PullRequest { ref action, ref sender, .. } => {
               println!("sender {} action {}", sender.login, action)
           },
           _ => ()
       }
    });
    let srv = Server::http("0.0.0.0:4567").unwrap()
       .handle(hub.handle);
    println!("hub is up");
    srv.unwrap();
}

and error is

trait `for<'r, 'r, 'r> afterparty::Hub: std::ops::FnOnce<(hyper::server::Request<'r, 'r>, hyper::server::Response<'r>)>` not satisfied

What's the reason?

softprops commented 7 years ago

hi @ggaaooppeenngg I updated example in the readme and published a new version 0.1.1. Can you let me know if you're still having a compile issue after you try that.

ggaaooppeenngg commented 7 years ago

@softprops Which version of hyper are you using? I new to rust, I guess it is a handler interface break? I don't know how to modify it to work with the latest hyper.

softprops commented 7 years ago

I'm depending on the latest release. 0.9

ggaaooppeenngg commented 7 years ago

Oh I set it to the 0.7.2, but change to 0.9, it works. BTW in the README.md

let svc = Server::http("0.0.0.0:4567")
       .unwrap(); <=== this semicolon seems redundant.
       .handle(hub);`
softprops commented 7 years ago

Nice catch. Thanks!