mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-05 10:06:10 +00:00
[rust-server] Plaintext support; encode params (#7082)
* MMORCH-428: Export the Authorization struct This is needed so that code can check that the version of Authorization in the auto-generated code is the same as the version it is using. If the versions are not exactly the same then the lookup into the TypeMap will not work. * Add Rust as a supported language for client and server. Clarify that there are two Rust client implementations, and one Rust server implementation. * Percent-encode path and query parameters in client URLs Fixes #122 Also don't include a question mark at the end of the path when there are no query paramters. Fixes #121 * Rust2 client: add --host and --port parameters to example client. Allows the example command-line client to override the default host and port. * Extract default host and port from Swagger file. * Derive 'Eq' and 'Ord' on enums * Rust2: improve server code structure. server.rs (main.rs) - main entry point for binary; starts the web server and points it at the server code within the library. server_lib/mod.rs (lib.rs) - root of library; creates the server. server_lib/server.rs (server.rs) - actual server code The old server_lib/mod.rs is now server_lib/server.rs; server_lib/mod.rs is new. This structure is easy to map onto a server implementation; unfortunately we can't get it exactly right here because of the limitations of cargo's examples/ folder. * Rust2: Explain fully how to use the example code in your project. * Added plaintext support * Linting * MGJ Markups
This commit is contained in:
committed by
William Cheng
parent
20f48b04fc
commit
1a831f73f3
@@ -1,11 +1,22 @@
|
||||
//! Main binary entry point for petstore_api implementation.
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
// Imports required by this file.
|
||||
// extern crate <name of this crate>;
|
||||
extern crate petstore_api;
|
||||
extern crate swagger;
|
||||
extern crate iron;
|
||||
extern crate futures;
|
||||
extern crate hyper_openssl;
|
||||
extern crate clap;
|
||||
extern crate swagger;
|
||||
|
||||
// Imports required by server library.
|
||||
// extern crate petstore_api;
|
||||
// extern crate swagger;
|
||||
extern crate futures;
|
||||
extern crate chrono;
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
|
||||
use hyper_openssl::OpensslServer;
|
||||
use hyper_openssl::openssl::x509::X509_FILETYPE_PEM;
|
||||
@@ -15,7 +26,6 @@ use clap::{App, Arg};
|
||||
use iron::{Iron, Chain};
|
||||
use swagger::auth::AllowAllMiddleware;
|
||||
|
||||
// Import the module that defines the Server struct.
|
||||
mod server_lib;
|
||||
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
@@ -39,7 +49,7 @@ fn main() {
|
||||
.help("Whether to use HTTPS or not"))
|
||||
.get_matches();
|
||||
|
||||
let server = server_lib::Server{};
|
||||
let server = server_lib::server().unwrap();
|
||||
let router = petstore_api::router(server);
|
||||
|
||||
let mut chain = Chain::new(router);
|
||||
@@ -50,9 +60,9 @@ fn main() {
|
||||
|
||||
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");
|
||||
Iron::new(chain).https("localhost:80", 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");
|
||||
Iron::new(chain).http("localhost:80").expect("Failed to start HTTP server");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user