From a7646d50826e6384578a5c35fc87013b63cd909e Mon Sep 17 00:00:00 2001 From: tottoto Date: Sun, 1 Oct 2023 13:18:00 +0900 Subject: [PATCH] feat(lib): add upgrade feature --- Cargo.toml | 9 ++++++--- src/lib.rs | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4c6ac0e9f7..b8e14af0cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,12 +31,12 @@ h2 = { version = "0.3.9", optional = true } itoa = "1" tracing = { version = "0.1", default-features = false, features = ["std"] } pin-project-lite = "0.2.4" -tokio = { version = "1", features = ["sync"] } # Optional httpdate = { version = "1.0", optional = true } libc = { version = "0.2", optional = true } +tokio = { version = "1", features = ["sync"], optional = true } want = { version = "0.3", optional = true } [dev-dependencies] @@ -74,13 +74,16 @@ full = [ ] # HTTP versions -http1 = [] -http2 = ["dep:h2"] +http1 = ["upgrade"] +http2 = ["upgrade", "dep:h2"] # Client/Server client = ["dep:want"] server = ["dep:httpdate"] +# HTTP Upgrades +upgrade = ["dep:tokio"] + # C-API support (currently unstable (no semver)) ffi = ["dep:libc", "dep:http-body-util"] diff --git a/src/lib.rs b/src/lib.rs index 7de04debc3..d658916968 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,8 +49,10 @@ //! - `http2`: Enables HTTP/2 support. //! - `client`: Enables the HTTP `client`. //! - `server`: Enables the HTTP `server`. +//! - `upgrade`: Enables [HTTP Upgrades]. //! //! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section +//! [Http Upgrades]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism #[doc(hidden)] pub use http; @@ -76,7 +78,6 @@ pub mod ext; mod mock; pub mod rt; pub mod service; -pub mod upgrade; #[cfg(feature = "ffi")] #[cfg_attr(docsrs, doc(cfg(all(feature = "ffi", hyper_unstable_ffi))))] @@ -98,3 +99,9 @@ cfg_feature! { pub mod server; } + +cfg_feature! { + #![feature = "upgrade"] + + pub mod upgrade; +}