Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rust Server] Hyper 0.13 + Async/Await support #6244

Merged
merged 5 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ client = [
"serde_ignored", "regex", "percent-encoding", "lazy_static",
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list below }}
"hyper", "hyper-openssl", "native-tls", "openssl", "url"
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
]
server = [
{{#apiUsesMultipart}}
Expand All @@ -40,7 +40,7 @@ server = [
"hyper_0_10", "mime_multipart",
{{/apiUsesMultipartRelated}}
{{#hasCallbacks}}
"native-tls", "hyper-openssl", "openssl",
"native-tls", "hyper-openssl", "hyper-tls", "openssl",
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list above }}
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
Expand All @@ -49,20 +49,22 @@ conversion = ["frunk", "frunk_derives", "frunk_core", "frunk-enum-core", "frunk-

[target.'cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))'.dependencies]
native-tls = { version = "0.2", optional = true }
hyper-tls = { version = "0.4", optional = true }

[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dependencies]
hyper-openssl = { version = "0.7.1", optional = true }
hyper-openssl = { version = "0.8", optional = true }
openssl = {version = "0.10", optional = true }

[dependencies]
# Common
async-trait = "0.1.24"
chrono = { version = "0.4", features = ["serde"] }
futures = "0.1"
swagger = "4.0"
futures = "0.3"
swagger = "5.0.0-alpha-1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an alpha release, mainly because the Hyper 0.13 code here is so new. I'll cut a 5.0 release of swagger prior to 5.0 of OpenAPI Generator being released, and update this to match.

log = "0.4.0"
mime = "0.3"

serde = { version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Crates included if required by the API definition
Expand All @@ -78,27 +80,27 @@ mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
multipart = { version = "0.16", default-features = false, optional = true }
{{/apiUsesMultipartFormData}}
{{#apiUsesUuid}}
uuid = {version = "0.7", features = ["serde", "v4"]}
uuid = {version = "0.8", features = ["serde", "v4"]}
{{/apiUsesUuid}}

# Common between server and client features
hyper = {version = "0.12", optional = true}
hyper = {version = "0.13", optional = true}
{{#apiUsesMultipartRelated}}
mime_multipart = {version = "0.5", optional = true}
hyper_0_10 = {package = "hyper", version = "0.10", default-features = false, optional=true}
{{/apiUsesMultipartRelated}}
serde_ignored = {version = "0.0.4", optional = true}
url = {version = "1.5", optional = true}
serde_ignored = {version = "0.1.1", optional = true}
url = {version = "2.1", optional = true}

# Client-specific
{{#usesUrlEncodedForm}}
serde_urlencoded = {version = "0.5.1", optional = true}
serde_urlencoded = {version = "0.6.1", optional = true}
{{/usesUrlEncodedForm}}

# Server, and client callback-specific
lazy_static = { version = "1.4", optional = true }
percent-encoding = {version = "1.0.0", optional = true}
regex = {version = "0.2", optional = true}
percent-encoding = {version = "2.1.0", optional = true}
regex = {version = "1.3", optional = true}

# Conversion
frunk = { version = "0.3.0", optional = true }
Expand All @@ -109,15 +111,13 @@ frunk-enum-core = { version = "0.2.0", optional = true }

[dev-dependencies]
clap = "2.25"
error-chain = "0.12"
env_logger = "0.6"
tokio = "0.1.17"
{{^apiUsesUuid}}
uuid = {version = "0.7", features = ["serde", "v4"]}
{{/apiUsesUuid}}
env_logger = "0.7"
tokio = { version = "0.2", features = ["rt-threaded", "macros", "stream"] }
native-tls = "0.2"
tokio-tls = "0.3"

[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
tokio-openssl = "0.3"
tokio-openssl = "0.4"
openssl = "0.10"

[[example]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
use futures;
use futures::{Future, Stream, future, stream};
use hyper;
use hyper::client::HttpConnector;
use async_trait::async_trait;
use futures::{Stream, future, future::BoxFuture, stream, future::TryFutureExt, future::FutureExt, stream::StreamExt};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use hyper::{Body, Uri, Response};
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
use hyper_openssl::HttpsConnector;
use serde_json;
use hyper::{Body, Request, Response, service::Service, Uri};
use percent_encoding::{utf8_percent_encode, AsciiSet};
use std::borrow::Cow;
use std::convert::TryInto;
use std::io::{Read, Error, ErrorKind};
use std::error;
use std::io::{ErrorKind, Read};
use std::error::Error;
use std::future::Future;
use std::fmt;
use std::path::Path;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use std::str;
use std::str::FromStr;
use std::string::ToString;
use swagger;
use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData};
use std::task::{Context, Poll};
use swagger::{ApiError, AuthData, BodyExt, Connector, Has, XSpanIdString};
use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};

{{#apiUsesMultipartFormData}}
use mime::Mime;
use std::io::Cursor;
Expand All @@ -30,20 +27,18 @@ use multipart::client::lazy::Multipart;
use hyper_0_10::header::{Headers, ContentType};
use mime_multipart::{Node, Part, generate_boundary, write_multipart};
{{/apiUsesMultipartRelated}}
{{#apiUsesUuid}}
use uuid;
{{/apiUsesUuid}}
{{#usesXml}}
use serde_xml_rs;
{{/usesXml}}

use crate::models;
use crate::header;

url::define_encode_set! {
/// This encode set is used for object IDs
///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
/// the vertical bar (|) is encoded.
pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
}
/// https://url.spec.whatwg.org/#fragment-percent-encode-set
#[allow(dead_code)]
const FRAGMENT_ENCODE_SET: &AsciiSet = &percent_encoding::CONTROLS
.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');

/// This encode set is used for object IDs
///
/// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
/// the vertical bar (|) is encoded.
#[allow(dead_code)]
const ID_ENCODE_SET: &AsciiSet = &FRAGMENT_ENCODE_SET.add(b'|');
Loading