Skip to content

Instantly share code, notes, and snippets.

@wycats
Last active January 3, 2016 00:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wycats/8380393 to your computer and use it in GitHub Desktop.
Save wycats/8380393 to your computer and use it in GitHub Desktop.
fn main() {
do RoutedServer::serve |config, router| {
config.listen("127.0.0.1", 1337);
router.get("/hello", |_,res| res.write("hello world"));
router.get("/posts/:id", |req,res| {
res.write(format!("post {}", req.params["id"]))
});
}
}
@wycats
Copy link
Author

wycats commented Jan 12, 2014

Line 3 was a bug. Line 8 probably should have a semicolon but write() returns () so it doesn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment