Skip to content

Instantly share code, notes, and snippets.

@timonv
Created February 18, 2015 06:55
Show Gist options
  • Save timonv/504a79596e7027a9f40c to your computer and use it in GitHub Desktop.
Save timonv/504a79596e7027a9f40c to your computer and use it in GitHub Desktop.
fn main() {
// Command::new("xdg-open").arg("https://slack.com/oauth/authorize?client_id=2334733471.3592055147").output().unwrap();
let server = Server::http(Ipv4Addr(127, 0, 0, 1), 9999);
let (tx, rx) = channel();
// tx.send("Test".to_string());
// rx.recv();
let mut _guard = server.listen(move |req: Request, res: Response| {
match req.uri {
AbsolutePath(path) => {
let authcode = extract_auth_code(&path).unwrap();
tx.send(authcode);
},
_ => ()
}
let mut res = res.start().unwrap();
res.write(b"Thanks! Please return to Lax");
res.end().unwrap();
}).unwrap();
println!("{}", rx.recv().unwrap());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment