Created
July 27, 2016 14:43
-
-
Save flosse/da963de2bbb466bdca09c23757b070ce to your computer and use it in GitHub Desktop.
iron-write-to-body
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
[package] | |
name = "iron-wirte-to-body" | |
version = "0.1.0" | |
authors = ["Markus Kohlhase <mail@markus-kohlhase.de>"] | |
[dependencies] | |
iron = "*" | |
maud = "*" | |
maud_macros = "*" |
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
#![feature(plugin)] | |
#![plugin(maud_macros)] | |
extern crate iron; | |
extern crate maud; | |
use iron::prelude::*; | |
use iron::status; | |
fn main() { | |
fn write_to_body(_: &mut Request) -> IronResult<Response> { | |
let world = "world"; | |
let res = Response::new(); | |
let mut body_buffer:Vec<u8> = vec!(); // <-- how to connect it to 'res'? | |
html_utf8!(body_buffer, { | |
html { | |
body { | |
h1 "Write to body!" | |
p "Hello " ^world "!" | |
} | |
} | |
}).unwrap(); | |
Ok(Response::with((status::Ok, "Hello World!"))) | |
} | |
Iron::new(write_to_body).http("localhost:3000").unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment