Created
February 18, 2015 06:55
-
-
Save timonv/504a79596e7027a9f40c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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