-
-
Save steveklabnik/75711e6adfc1b37e8d3c to your computer and use it in GitHub Desktop.
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
#[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(); | |
let yaml = get_yaml(); | |
server.utilize(router! { | |
get "**" => |_req, _res| { | |
&*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