mirror of
https://github.com/fafhrd91/actix-web
synced 2025-02-17 10:13:30 +01:00
feat: forwards-compatibility for handler visibility inheritance fix (#3391)
This commit is contained in:
parent
7c4c26d2df
commit
ebc43dcf1b
@ -3,6 +3,7 @@
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Add `#[scope]` macro.
|
- Add `#[scope]` macro.
|
||||||
|
- Add `compat-routing-macros-force-pub` crate feature which, on-by-default, which when disabled causes handlers to inherit their attached function's visibility.
|
||||||
- Prevent inclusion of default `actix-router` features.
|
- Prevent inclusion of default `actix-router` features.
|
||||||
- Minimum supported Rust version (MSRV) is now 1.72.
|
- Minimum supported Rust version (MSRV) is now 1.72.
|
||||||
|
|
||||||
|
@ -15,6 +15,10 @@ rust-version.workspace = true
|
|||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["compat-routing-macros-force-pub"]
|
||||||
|
compat-routing-macros-force-pub = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-router = { version = "0.5", default-features = false }
|
actix-router = { version = "0.5", default-features = false }
|
||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
|
@ -413,6 +413,13 @@ impl ToTokens for Route {
|
|||||||
doc_attributes,
|
doc_attributes,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
|
#[allow(unused_variables)] // used when force-pub feature is disabled
|
||||||
|
let vis = &ast.vis;
|
||||||
|
|
||||||
|
// TODO(breaking): remove this force-pub forwards-compatibility feature
|
||||||
|
#[cfg(feature = "compat-routing-macros-force-pub")]
|
||||||
|
let vis = syn::Visibility::Public(<Token![pub]>::default());
|
||||||
|
|
||||||
let registrations: TokenStream2 = args
|
let registrations: TokenStream2 = args
|
||||||
.iter()
|
.iter()
|
||||||
.map(|args| {
|
.map(|args| {
|
||||||
@ -460,7 +467,7 @@ impl ToTokens for Route {
|
|||||||
let stream = quote! {
|
let stream = quote! {
|
||||||
#(#doc_attributes)*
|
#(#doc_attributes)*
|
||||||
#[allow(non_camel_case_types, missing_docs)]
|
#[allow(non_camel_case_types, missing_docs)]
|
||||||
pub struct #name;
|
#vis struct #name;
|
||||||
|
|
||||||
impl ::actix_web::dev::HttpServiceFactory for #name {
|
impl ::actix_web::dev::HttpServiceFactory for #name {
|
||||||
fn register(self, __config: &mut actix_web::dev::AppService) {
|
fn register(self, __config: &mut actix_web::dev::AppService) {
|
||||||
|
@ -49,7 +49,7 @@ mod scope_module {
|
|||||||
#[connect("/test2")]
|
#[connect("/test2")]
|
||||||
#[options("/test3")]
|
#[options("/test3")]
|
||||||
#[trace("/test4")]
|
#[trace("/test4")]
|
||||||
async fn multiple_separate_paths() -> impl Responder {
|
pub async fn multiple_separate_paths() -> impl Responder {
|
||||||
HttpResponse::Ok().finish()
|
HttpResponse::Ok().finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
- Add `middleware::Identity` type.
|
- Add `middleware::Identity` type.
|
||||||
- Add `CustomizeResponder::add_cookie()` method.
|
- Add `CustomizeResponder::add_cookie()` method.
|
||||||
- Add `guard::GuardContext::app_data()` method.
|
- Add `guard::GuardContext::app_data()` method.
|
||||||
|
- Add `compat-routing-macros-force-pub` crate feature which (on-by-default) which, when disabled, causes handlers to inherit their attached function's visibility.
|
||||||
|
- Add `compat` crate feature group (on-by-default) which, when disabled, helps with transitioning to some planned v5.0 breaking changes, starting only with `compat-routing-macros-force-pub`.
|
||||||
- Implement `From<Box<dyn ResponseError>>` for `Error`.
|
- Implement `From<Box<dyn ResponseError>>` for `Error`.
|
||||||
|
|
||||||
## 4.6.0
|
## 4.6.0
|
||||||
|
@ -40,7 +40,16 @@ name = "actix_web"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2", "unicode"]
|
default = [
|
||||||
|
"macros",
|
||||||
|
"compress-brotli",
|
||||||
|
"compress-gzip",
|
||||||
|
"compress-zstd",
|
||||||
|
"cookies",
|
||||||
|
"http2",
|
||||||
|
"unicode",
|
||||||
|
"compat",
|
||||||
|
]
|
||||||
|
|
||||||
# Brotli algorithm content-encoding support
|
# Brotli algorithm content-encoding support
|
||||||
compress-brotli = ["actix-http/compress-brotli", "__compress"]
|
compress-brotli = ["actix-http/compress-brotli", "__compress"]
|
||||||
@ -50,14 +59,15 @@ compress-gzip = ["actix-http/compress-gzip", "__compress"]
|
|||||||
compress-zstd = ["actix-http/compress-zstd", "__compress"]
|
compress-zstd = ["actix-http/compress-zstd", "__compress"]
|
||||||
|
|
||||||
# Routing and runtime proc macros
|
# Routing and runtime proc macros
|
||||||
macros = ["actix-macros", "actix-web-codegen"]
|
macros = ["dep:actix-macros", "dep:actix-web-codegen"]
|
||||||
|
|
||||||
# Cookies support
|
# Cookies support
|
||||||
cookies = ["cookie"]
|
cookies = ["dep:cookie"]
|
||||||
|
|
||||||
# Secure & signed cookies
|
# Secure & signed cookies
|
||||||
secure-cookies = ["cookies", "cookie/secure"]
|
secure-cookies = ["cookies", "cookie/secure"]
|
||||||
|
|
||||||
|
# HTTP/2 support (including h2c).
|
||||||
http2 = ["actix-http/http2"]
|
http2 = ["actix-http/http2"]
|
||||||
|
|
||||||
# TLS via OpenSSL
|
# TLS via OpenSSL
|
||||||
@ -84,6 +94,14 @@ __compress = []
|
|||||||
# io-uring feature only available for Linux OSes.
|
# io-uring feature only available for Linux OSes.
|
||||||
experimental-io-uring = ["actix-server/io-uring"]
|
experimental-io-uring = ["actix-server/io-uring"]
|
||||||
|
|
||||||
|
# Feature group which, when disabled, helps migrate code to v5.0.
|
||||||
|
compat = [
|
||||||
|
"compat-routing-macros-force-pub",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Opt-out forwards-compatibility for handler visibility inheritance fix.
|
||||||
|
compat-routing-macros-force-pub = ["actix-web-codegen?/compat-routing-macros-force-pub"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.5"
|
actix-codec = "0.5"
|
||||||
actix-macros = { version = "0.2.3", optional = true }
|
actix-macros = { version = "0.2.3", optional = true }
|
||||||
@ -95,7 +113,7 @@ actix-tls = { version = "3.4", default-features = false, optional = true }
|
|||||||
|
|
||||||
actix-http = { version = "3.7", features = ["ws"] }
|
actix-http = { version = "3.7", features = ["ws"] }
|
||||||
actix-router = { version = "0.5.3", default-features = false, features = ["http"] }
|
actix-router = { version = "0.5.3", default-features = false, features = ["http"] }
|
||||||
actix-web-codegen = { version = "4.2", optional = true }
|
actix-web-codegen = { version = "4.2", optional = true, default-features = false }
|
||||||
|
|
||||||
ahash = "0.8"
|
ahash = "0.8"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
|
@ -64,7 +64,7 @@ compress-gzip = ["actix-http/compress-gzip", "__compress"]
|
|||||||
compress-zstd = ["actix-http/compress-zstd", "__compress"]
|
compress-zstd = ["actix-http/compress-zstd", "__compress"]
|
||||||
|
|
||||||
# Cookie parsing and cookie jar
|
# Cookie parsing and cookie jar
|
||||||
cookies = ["cookie"]
|
cookies = ["dep:cookie"]
|
||||||
|
|
||||||
# Use `trust-dns-resolver` crate as DNS resolver
|
# Use `trust-dns-resolver` crate as DNS resolver
|
||||||
trust-dns = ["trust-dns-resolver"]
|
trust-dns = ["trust-dns-resolver"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user