Last active
September 29, 2015 05:04
-
-
Save brianloveswords/33cae0ff7b2246b3475c 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
extern crate hyper; | |
extern crate uuid; | |
use uuid::Uuid; | |
use hyper::server::{Request, Response}; | |
use std::io::Read; | |
// If a github webhook client requests this route, after serving that request successfully | |
// it will never respond to another request from any client again. | |
fn hello(req: Request, res: Response) { | |
let mut req = req; | |
let task_id = Uuid::new_v4(); | |
println!("[{}]: request received, processing", task_id); | |
println!("[{}]: loading body into string", task_id); | |
let mut payload = String::new(); | |
if req.read_to_string(&mut payload).is_err() { | |
println!("[{}]: could not read body into string", task_id); | |
return res.send(b"nope").unwrap(); | |
} | |
println!("[{}]: done, responding", task_id); | |
res.send(b"yep").unwrap(); | |
} | |
fn main() { | |
let _listening = hyper::Server::http("0.0.0.0:4200").unwrap() | |
.handle(hello); | |
println!("Listening on 0.0.0.0:4200"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment