Created
February 22, 2017 01:25
-
-
Save campaul/941d178bed307e4c664a41d828af43c6 to your computer and use it in GitHub Desktop.
Simple response! macro for Iron with example.
This file contains hidden or 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 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