Created
August 17, 2016 22:38
-
-
Save Cobrand/5a7a9e175da8c50b3767e21c3df4dc14 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 iron; | |
use std::sync::mpsc::* ; | |
use iron::prelude::*; | |
use iron::{Listening,status}; | |
fn main() { | |
let (tx,rx) = channel() ; | |
let handler = move |request: &mut Request| { | |
let tx = tx.clone(); | |
tx.send(5i32); | |
Ok(Response::with(status::Ok)) | |
}; | |
let listening = Iron::new(handler).http("0.0.0.0:8080").unwrap(); | |
loop { | |
if let Ok(value) = rx.try_recv() { | |
// do something | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment