mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 10:42:55 +01:00
Add http2 optional feature (#3072)
Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
parent
79a38e0628
commit
bf03207ca9
@ -40,7 +40,7 @@ serde_json = "1"
|
|||||||
serde_plain = "1"
|
serde_plain = "1"
|
||||||
# TODO(MSRV 1.60): replace with dep: prefix
|
# TODO(MSRV 1.60): replace with dep: prefix
|
||||||
tempfile-dep = { package = "tempfile", version = "3.4", optional = true }
|
tempfile-dep = { package = "tempfile", version = "3.4", optional = true }
|
||||||
tokio = { version = "1.24.2", features = ["sync"] }
|
tokio = { version = "1.24.2", features = ["io-util", "sync"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-http = "3"
|
actix-http = "3"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Add `HttpServer::{bind,listen}_auto_h2c()` method.
|
- Add `HttpServer::{bind, listen}_auto_h2c()` method behind new `http2` crate feature.
|
||||||
- Add `Resource::{get, post, etc...}` methods for more concisely adding routes that don't need additional guards.
|
- Add `Resource::{get, post, etc...}` methods for more concisely adding routes that don't need additional guards.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -28,7 +28,7 @@ name = "actix_web"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies"]
|
default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2"]
|
||||||
|
|
||||||
# Brotli algorithm content-encoding support
|
# Brotli algorithm content-encoding support
|
||||||
compress-brotli = ["actix-http/compress-brotli", "__compress"]
|
compress-brotli = ["actix-http/compress-brotli", "__compress"]
|
||||||
@ -46,11 +46,13 @@ cookies = ["cookie"]
|
|||||||
# Secure & signed cookies
|
# Secure & signed cookies
|
||||||
secure-cookies = ["cookies", "cookie/secure"]
|
secure-cookies = ["cookies", "cookie/secure"]
|
||||||
|
|
||||||
|
http2 = ["actix-http/http2"]
|
||||||
|
|
||||||
# TLS via OpenSSL
|
# TLS via OpenSSL
|
||||||
openssl = ["actix-http/openssl", "actix-tls/accept", "actix-tls/openssl"]
|
openssl = ["http2", "actix-http/openssl", "actix-tls/accept", "actix-tls/openssl"]
|
||||||
|
|
||||||
# TLS via Rustls
|
# TLS via Rustls
|
||||||
rustls = ["actix-http/rustls", "actix-tls/accept", "actix-tls/rustls"]
|
rustls = ["http2", "actix-http/rustls", "actix-tls/accept", "actix-tls/rustls"]
|
||||||
|
|
||||||
# Internal (PRIVATE!) features used to aid testing and checking feature status.
|
# Internal (PRIVATE!) features used to aid testing and checking feature status.
|
||||||
# Don't rely on these whatsoever. They may disappear at anytime.
|
# Don't rely on these whatsoever. They may disappear at anytime.
|
||||||
@ -68,7 +70,7 @@ actix-service = "2"
|
|||||||
actix-utils = "3"
|
actix-utils = "3"
|
||||||
actix-tls = { version = "3", default-features = false, optional = true }
|
actix-tls = { version = "3", default-features = false, optional = true }
|
||||||
|
|
||||||
actix-http = { version = "3.3", features = ["http2", "ws"] }
|
actix-http = { version = "3.3", features = ["ws"] }
|
||||||
actix-router = "0.5"
|
actix-router = "0.5"
|
||||||
actix-web-codegen = { version = "4.2", optional = true }
|
actix-web-codegen = { version = "4.2", optional = true }
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ impl ResourceMap {
|
|||||||
"`pattern` and `nested` mismatch"
|
"`pattern` and `nested` mismatch"
|
||||||
);
|
);
|
||||||
// parents absorb references to the named resources of children
|
// parents absorb references to the named resources of children
|
||||||
self.named.extend(new_node.named.clone().into_iter());
|
self.named.extend(new_node.named.clone());
|
||||||
self.nodes.as_mut().unwrap().push(new_node);
|
self.nodes.as_mut().unwrap().push(new_node);
|
||||||
} else {
|
} else {
|
||||||
let new_node = Rc::new(ResourceMap {
|
let new_node = Rc::new(ResourceMap {
|
||||||
|
@ -356,6 +356,7 @@ where
|
|||||||
|
|
||||||
/// Resolves socket address(es) and binds server to created listener(s) for plaintext HTTP/1.x
|
/// Resolves socket address(es) and binds server to created listener(s) for plaintext HTTP/1.x
|
||||||
/// or HTTP/2 connections.
|
/// or HTTP/2 connections.
|
||||||
|
#[cfg(feature = "http2")]
|
||||||
pub fn bind_auto_h2c<A: net::ToSocketAddrs>(mut self, addrs: A) -> io::Result<Self> {
|
pub fn bind_auto_h2c<A: net::ToSocketAddrs>(mut self, addrs: A) -> io::Result<Self> {
|
||||||
let sockets = bind_addrs(addrs, self.backlog)?;
|
let sockets = bind_addrs(addrs, self.backlog)?;
|
||||||
|
|
||||||
@ -453,6 +454,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Binds to existing listener for accepting incoming plaintext HTTP/1.x or HTTP/2 connections.
|
/// Binds to existing listener for accepting incoming plaintext HTTP/1.x or HTTP/2 connections.
|
||||||
|
#[cfg(feature = "http2")]
|
||||||
pub fn listen_auto_h2c(mut self, lst: net::TcpListener) -> io::Result<Self> {
|
pub fn listen_auto_h2c(mut self, lst: net::TcpListener) -> io::Result<Self> {
|
||||||
let cfg = self.config.clone();
|
let cfg = self.config.clone();
|
||||||
let factory = self.factory.clone();
|
let factory = self.factory.clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user