Skip to content

Instantly share code, notes, and snippets.

@flosse
Created July 27, 2016 14:43
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 flosse/da963de2bbb466bdca09c23757b070ce to your computer and use it in GitHub Desktop.
Save flosse/da963de2bbb466bdca09c23757b070ce to your computer and use it in GitHub Desktop.
iron-write-to-body
[package]
name = "iron-wirte-to-body"
version = "0.1.0"
authors = ["Markus Kohlhase <mail@markus-kohlhase.de>"]
[dependencies]
iron = "*"
maud = "*"
maud_macros = "*"
#![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