Skip to content

Instantly share code, notes, and snippets.

@campaul
Created February 22, 2017 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save campaul/941d178bed307e4c664a41d828af43c6 to your computer and use it in GitHub Desktop.
Save campaul/941d178bed307e4c664a41d828af43c6 to your computer and use it in GitHub Desktop.
Simple response! macro for Iron with example.
extern crate iron;
use iron::prelude::*;
macro_rules! response {
( $( $x:expr ),* ) => {
{
Ok(Response::with(($(
$x,
)*)))
}
};
}
fn hello_world(_: &mut Request) -> IronResult<Response> {
response!(iron::status::Ok, "Hello World")
}
fn main() {
Iron::new(hello_world).http("localhost:3000").unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment