forked from loafle/openapi-generator-original
[Rust Server] Fix server example on non-Linux (#7399)
* [Rust Server] Fix server example on non-Linux The server example is broken because it tries to import `use openssl::ssl::SslAcceptorBuilder;` unconditionally when it won't be present on MacOS, Windows or iOS and then conditionally provides `create` causing compile errors on the aforementioned platforms. To fix, we simply move the condition from the function to the import and all is happy again :) * Update Samples Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use {{{externCrateName}}}::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use multipart_v3::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use no_example_v3::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use openapi_v3::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use openapi_v3::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use ops_v3::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use petstore_with_fake_endpoints_models_for_testing::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use hyper::server::conn::Http;
|
||||
use hyper::service::Service;
|
||||
use log::info;
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
use openssl::ssl::SslAcceptorBuilder;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
@@ -23,7 +24,6 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use rust_server_test::models;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
|
||||
/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
|
||||
pub async fn create(addr: &str, https: bool) {
|
||||
let addr = addr.parse().expect("Failed to parse bind address");
|
||||
|
||||
Reference in New Issue
Block a user