#![allow(missing_docs)] extern crate chrono; extern crate clap; extern crate fatcat; extern crate fatcat_api; extern crate futures; extern crate iron; extern crate swagger; #[macro_use] extern crate error_chain; use clap::{App, Arg}; use iron::{Chain, Iron}; use swagger::auth::AllowAllMiddleware; /// Create custom server, wire it to the autogenerated router, /// and pass it to the web server. fn main() { let matches = App::new("server") .arg( Arg::with_name("https") .long("https") .help("Whether to use HTTPS or not"), ) .get_matches(); let server = fatcat::server().unwrap(); let router = fatcat_api::router(server); let mut chain = Chain::new(router); chain.link_before(fatcat_api::server::ExtractAuthData); // add authentication middlewares into the chain here // for the purpose of this example, pretend we have authenticated a user chain.link_before(AllowAllMiddleware::new("cosmo")); if matches.is_present("https") { unimplemented!() } else { // Using HTTP Iron::new(chain) .http("localhost:8080") .expect("Failed to start HTTP server"); } }