Skip to content

Instantly share code, notes, and snippets.

@jroweboy
Created June 4, 2014 21:33
Show Gist options
  • Save jroweboy/f830462ccd048725433e to your computer and use it in GitHub Desktop.
Save jroweboy/f830462ccd048725433e to your computer and use it in GitHub Desktop.
Quick Fix?
impl Server {
fn new(route_store: Arc<RWLock<RouteStore>>) -> Server {
Server {
route_store: route_store
}
}
}
impl Floor {
pub fn get(&mut self, uri: &str, handler: fn(request: &Request, response: &mut ResponseWriter) -> ()){
self.route_store.routes.insert(String::from_str(uri), handler);
}
pub fn new() -> Floor {
Floor {
route_store: Arc::new(RWLock::new(RouteStore::new())),
server: None
}
}
//why do we need this. Is serve_forever like a protected method in C# terms?
pub fn run(&mut self) -> () {
self.server = Some(Server::new(self.route_store.clone()));
self.server.unwrap().serve_forever();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment