diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index b5a389f7a..cd7e48165 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -94,7 +94,7 @@ jobs: run: cargo install cargo-hack - name: check --feature-powerset - run: cargo hack check --feature-powerset --depth 1 -Z avoid-dev-deps + run: cargo hack check --feature-powerset --depth 1 -Z avoid-dev-deps --exclude-features server cover: strategy: diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 2d59cd374..2b9135df5 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -16,11 +16,12 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] -default = ["cookie", "http1", "fix-http1-request-uri", "http2", "test"] -full = ["cookie", "http1", "fix-http1-request-uri", "http2", "quinn", "rustls", "native-tls", "openssl", "unix", "test", "tower-compat", "anyhow", "eyre"] +default = ["cookie", "fix-http1-request-uri", "server", "http1", "http2"] +full = ["cookie", "fix-http1-request-uri", "server", "http1", "http2", "quinn", "rustls", "native-tls", "openssl", "unix", "test", "tower-compat", "anyhow", "eyre"] cookie = ["dep:cookie"] -http1 = [] fix-http1-request-uri = ["http1"] +server = [] +http1 = [] http2 = ["hyper/http2"] quinn = ["dep:salvo-http3", "dep:quinn", "dep:tokio-rustls-old", "dep:rustls-pemfile-old", "rustls"] rustls = ["http1", "http2", "dep:tokio-rustls", "dep:rustls-pemfile"] diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index f30757582..dbed6422e 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -33,7 +33,11 @@ pub mod routing; pub mod rt; #[doc(hidden)] pub mod serde; -pub mod server; +cfg_feature! { + #![feature ="server"] + pub mod server; + pub use self::server::Server; +} mod service; pub mod writing; cfg_feature! { @@ -57,7 +61,6 @@ pub use self::extract::Extractible; pub use self::handler::Handler; pub use self::http::{Request, Response}; pub use self::routing::{FlowCtrl, Router}; -pub use self::server::Server; pub use self::service::Service; pub use self::writing::{Scribe, Writer}; /// Result type which has `salvo::Error` as it's error type. @@ -101,7 +104,10 @@ pub mod prelude { pub use crate::conn::{JoinedListener, Listener, TcpListener}; pub use crate::handler::{self, Handler}; pub use crate::routing::{FlowCtrl, Router}; - pub use crate::server::Server; + cfg_feature! { + #![feature = "server"] + pub use crate::server::Server; + } pub use crate::service::Service; pub use crate::writing::{Json, Redirect, Scribe, Text, Writer}; } diff --git a/crates/core/src/server.rs b/crates/core/src/server.rs index 9fcb58fdf..20c88cc97 100644 --- a/crates/core/src/server.rs +++ b/crates/core/src/server.rs @@ -3,6 +3,9 @@ use std::io::Result as IoResult; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +#[cfg(not(any(feature = "http1", feature = "http2", feature = "quinn")))] +compile_error!("You have enabled `server` feature, it requires at least one of the following features: http1, http2, quinn."); + #[cfg(feature = "http1")] use hyper::server::conn::http1; #[cfg(feature = "http2")] diff --git a/crates/oapi/Cargo.toml b/crates/oapi/Cargo.toml index 829ab6cdc..8a65f19b2 100644 --- a/crates/oapi/Cargo.toml +++ b/crates/oapi/Cargo.toml @@ -43,7 +43,6 @@ mime-infer = { workspace = true } once_cell = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -serde_urlencoded = { workspace = true } regex = { workspace = true } tokio = { workspace = true } tracing = { workspace = true } diff --git a/crates/salvo/Cargo.toml b/crates/salvo/Cargo.toml index fcb69c46c..732f77d9e 100644 --- a/crates/salvo/Cargo.toml +++ b/crates/salvo/Cargo.toml @@ -24,11 +24,12 @@ name = "salvo" path = "src/lib.rs" [features] -default = ["cookie", "http1", "fix-http1-request-uri", "http2", "test"] -full = ["cookie", "http1", "fix-http1-request-uri", "http2", "quinn", "rustls", "native-tls", "openssl", "unix", "acme", "tower-compat", "anyhow", "eyre", "test", "affix", "basic-auth", "force-https", "jwt-auth", "catch-panic", "compression", "logging", "proxy", "concurrency-limiter", "rate-limiter", "sse", "trailing-slash", "timeout", "websocket", "request-id", "caching-headers", "cache", "cors", "csrf", "flash", "rate-limiter", "session", "serve-static", "otel", "oapi"] +default = ["cookie", "fix-http1-request-uri", "server", "http1", "http2"] +full = ["cookie", "fix-http1-request-uri", "server", "http1", "http2", "quinn", "rustls", "native-tls", "openssl", "unix", "acme", "tower-compat", "anyhow", "eyre", "test", "affix", "basic-auth", "force-https", "jwt-auth", "catch-panic", "compression", "logging", "proxy", "concurrency-limiter", "rate-limiter", "sse", "trailing-slash", "timeout", "websocket", "request-id", "caching-headers", "cache", "cors", "csrf", "flash", "rate-limiter", "session", "serve-static", "otel", "oapi"] cookie = ["salvo_core/cookie"] -http1 = ["salvo_core/http1"] fix-http1-request-uri = ["salvo_core/fix-http1-request-uri"] +server = ["salvo_core/server"] +http1 = ["salvo_core/http1"] http2 = ["salvo_core/http2"] quinn = ["salvo_core/quinn"] rustls = ["salvo_core/rustls"]