From a9b23947c49275a11765c8a752c154b98c69b531 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 19 Sep 2019 00:38:00 -0700 Subject: WIP: update rust codegen script Only Cargo.toml project metadata updated. --- rust/fatcat-openapi/examples/server.rs | 59 ---------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 rust/fatcat-openapi/examples/server.rs (limited to 'rust/fatcat-openapi/examples/server.rs') diff --git a/rust/fatcat-openapi/examples/server.rs b/rust/fatcat-openapi/examples/server.rs deleted file mode 100644 index a033413b..00000000 --- a/rust/fatcat-openapi/examples/server.rs +++ /dev/null @@ -1,59 +0,0 @@ -//! Main binary entry point for fatcat implementation. - -#![allow(missing_docs)] - -// Imports required by this file. -// extern crate ; -use fatcat_openapi; - -// Imports required by server library. -// extern crate fatcat_openapi; -// extern crate swagger; -use chrono; -use futures; -#[macro_use] -extern crate error_chain; - -use clap::{App, Arg}; -use hyper_openssl::openssl::error::ErrorStack; -use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod}; -use hyper_openssl::openssl::x509::X509_FILETYPE_PEM; -use hyper_openssl::OpensslServer; -use iron::{Chain, Iron}; - -mod server_lib; - -/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names -fn ssl() -> Result { - let mut ssl = SslAcceptorBuilder::mozilla_intermediate_raw(SslMethod::tls())?; - - // Server authentication - ssl.set_private_key_file("examples/server-key.pem", X509_FILETYPE_PEM)?; - ssl.set_certificate_chain_file("examples/server-chain.pem")?; - ssl.check_private_key()?; - - Ok(OpensslServer::from(ssl.build())) -} - -/// 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 = server_lib::server().unwrap(); - let router = fatcat_openapi::router(server); - - let mut chain = Chain::new(router); - chain.link_before(fatcat_openapi::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") { - // Using Simple HTTPS - Iron::new(chain).https("localhost:8080", ssl().expect("Failed to load SSL keys")).expect("Failed to start HTTPS server"); - } else { - // Using HTTP - Iron::new(chain).http("localhost:8080").expect("Failed to start HTTP server"); - } -} -- cgit v1.2.3