-
-
Save mbrubeck/2fc3cbae1d30ce69cb00 to your computer and use it in GitHub Desktop.
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
#[macro_use] | |
extern crate nickel; | |
extern crate yaml_rust; | |
use nickel::{ Nickel, HttpRouter }; | |
use yaml_rust::{ Yaml, YamlEmitter }; | |
mod yaml_handler; | |
fn get_yaml() -> String { | |
let yaml = yaml_handler::from_file("test.yml"); | |
let mut yaml_str = String::new(); | |
// inject stuff | |
{ | |
let mut emitter = YamlEmitter::new(&mut yaml_str); | |
emitter.dump(&yaml[0]).unwrap(); | |
} | |
yaml_str | |
} | |
fn main() { | |
let mut server = Nickel::new(); | |
server.utilize(router! { | |
get "**" => |_req, _res| { | |
get_yaml() | |
} | |
}); | |
server.listen("127.0.0.1:6767"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment