mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-24 01:38:20 +02:00
Compare commits
6 Commits
from_fn
...
test-v0.1.
Author | SHA1 | Date | |
---|---|---|---|
|
a5c78483f9 | ||
|
12a0521ef8 | ||
|
b4faf8820c | ||
|
d6f885127d | ||
|
ebc43dcf1b | ||
|
7c4c26d2df |
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -89,5 +89,5 @@ jobs:
|
||||
- name: Generate API diff
|
||||
run: |
|
||||
for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do
|
||||
cargo public-api --manifest-path "$f" diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }}
|
||||
cargo public-api --manifest-path "$f" --simplified diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }}
|
||||
done
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 0.6.2
|
||||
|
||||
- Add testing utilities under new module `test`.
|
||||
- Minimum supported Rust version (MSRV) is now 1.72.
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-multipart"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Jacob Halsey <jacob@jhalsey.com>",
|
||||
|
@@ -5,11 +5,11 @@
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
[](https://crates.io/crates/actix-multipart)
|
||||
[](https://docs.rs/actix-multipart/0.6.1)
|
||||
[](https://docs.rs/actix-multipart/0.6.2)
|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-multipart/0.6.1)
|
||||
[](https://deps.rs/crate/actix-multipart/0.6.2)
|
||||
[](https://crates.io/crates/actix-multipart)
|
||||
[](https://discord.gg/NWpN5mmg3x)
|
||||
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 0.1.4
|
||||
|
||||
- Add `TestServerConfig::rustls_0_23()` method for Rustls v0.23 support behind new `rustls-0_23` crate feature.
|
||||
- Add `TestServerConfig::disable_redirects()` method.
|
||||
- Various types from `awc`, such as `ClientRequest` and `ClientResponse`, are now re-exported.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-test"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 4.3.0
|
||||
|
||||
- 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.
|
||||
- Minimum supported Rust version (MSRV) is now 1.72.
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-web-codegen"
|
||||
version = "4.2.2"
|
||||
version = "4.3.0"
|
||||
description = "Routing and runtime macros for Actix Web"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
@@ -15,6 +15,10 @@ rust-version.workspace = true
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[features]
|
||||
default = ["compat-routing-macros-force-pub"]
|
||||
compat-routing-macros-force-pub = []
|
||||
|
||||
[dependencies]
|
||||
actix-router = { version = "0.5", default-features = false }
|
||||
proc-macro2 = "1"
|
||||
|
@@ -5,11 +5,11 @@
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
[](https://crates.io/crates/actix-web-codegen)
|
||||
[](https://docs.rs/actix-web-codegen/4.2.2)
|
||||
[](https://docs.rs/actix-web-codegen/4.3.0)
|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-web-codegen/4.2.2)
|
||||
[](https://deps.rs/crate/actix-web-codegen/4.3.0)
|
||||
[](https://crates.io/crates/actix-web-codegen)
|
||||
[](https://discord.gg/NWpN5mmg3x)
|
||||
|
||||
|
@@ -413,6 +413,13 @@ impl ToTokens for Route {
|
||||
doc_attributes,
|
||||
} = 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
|
||||
.iter()
|
||||
.map(|args| {
|
||||
@@ -460,7 +467,7 @@ impl ToTokens for Route {
|
||||
let stream = quote! {
|
||||
#(#doc_attributes)*
|
||||
#[allow(non_camel_case_types, missing_docs)]
|
||||
pub struct #name;
|
||||
#vis struct #name;
|
||||
|
||||
impl ::actix_web::dev::HttpServiceFactory for #name {
|
||||
fn register(self, __config: &mut actix_web::dev::AppService) {
|
||||
|
@@ -49,7 +49,7 @@ mod scope_module {
|
||||
#[connect("/test2")]
|
||||
#[options("/test3")]
|
||||
#[trace("/test4")]
|
||||
async fn multiple_separate_paths() -> impl Responder {
|
||||
pub async fn multiple_separate_paths() -> impl Responder {
|
||||
HttpResponse::Ok().finish()
|
||||
}
|
||||
|
||||
|
@@ -2,10 +2,15 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 4.7.0
|
||||
|
||||
### Added
|
||||
|
||||
- Add `middleware::Identity` type.
|
||||
- Add `CustomizeResponder::add_cookie()` 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`.
|
||||
|
||||
## 4.6.0
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-web"
|
||||
version = "4.6.0"
|
||||
version = "4.7.0"
|
||||
description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
@@ -40,7 +40,16 @@ name = "actix_web"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[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
|
||||
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"]
|
||||
|
||||
# Routing and runtime proc macros
|
||||
macros = ["actix-macros", "actix-web-codegen"]
|
||||
macros = ["dep:actix-macros", "dep:actix-web-codegen"]
|
||||
|
||||
# Cookies support
|
||||
cookies = ["cookie"]
|
||||
cookies = ["dep:cookie"]
|
||||
|
||||
# Secure & signed cookies
|
||||
secure-cookies = ["cookies", "cookie/secure"]
|
||||
|
||||
# HTTP/2 support (including h2c).
|
||||
http2 = ["actix-http/http2"]
|
||||
|
||||
# TLS via OpenSSL
|
||||
@@ -84,6 +94,14 @@ __compress = []
|
||||
# io-uring feature only available for Linux OSes.
|
||||
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]
|
||||
actix-codec = "0.5"
|
||||
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-router = { version = "0.5.3", default-features = false, features = ["http"] }
|
||||
actix-web-codegen = { version = "4.2", optional = true }
|
||||
actix-web-codegen = { version = "4.3", optional = true, default-features = false }
|
||||
|
||||
ahash = "0.8"
|
||||
bytes = "1"
|
||||
|
@@ -8,10 +8,10 @@
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
[](https://crates.io/crates/actix-web)
|
||||
[](https://docs.rs/actix-web/4.6.0)
|
||||
[](https://docs.rs/actix-web/4.7.0)
|
||||

|
||||

|
||||
[](https://deps.rs/crate/actix-web/4.6.0)
|
||||
[](https://deps.rs/crate/actix-web/4.7.0)
|
||||
<br />
|
||||
[](https://github.com/actix/actix-web/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/actix/actix-web)
|
||||
|
@@ -38,15 +38,6 @@ pub struct Compat<T> {
|
||||
transform: T,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl Compat<super::Noop> {
|
||||
pub(crate) fn noop() -> Self {
|
||||
Self {
|
||||
transform: super::Noop,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Compat<T> {
|
||||
/// Wrap a middleware to give it broader compatibility.
|
||||
pub fn new(middleware: T) -> Self {
|
||||
@@ -152,7 +143,7 @@ mod tests {
|
||||
use crate::{
|
||||
dev::ServiceRequest,
|
||||
http::StatusCode,
|
||||
middleware::{self, Condition, Logger},
|
||||
middleware::{self, Condition, Identity, Logger},
|
||||
test::{self, call_service, init_service, TestRequest},
|
||||
web, App, HttpResponse,
|
||||
};
|
||||
@@ -225,7 +216,7 @@ mod tests {
|
||||
async fn compat_noop_is_noop() {
|
||||
let srv = test::ok_service();
|
||||
|
||||
let mw = Compat::noop()
|
||||
let mw = Compat::new(Identity)
|
||||
.new_transform(srv.into_service())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@@ -141,7 +141,7 @@ mod tests {
|
||||
header::{HeaderValue, CONTENT_TYPE},
|
||||
StatusCode,
|
||||
},
|
||||
middleware::{self, ErrorHandlerResponse, ErrorHandlers},
|
||||
middleware::{self, ErrorHandlerResponse, ErrorHandlers, Identity},
|
||||
test::{self, TestRequest},
|
||||
web::Bytes,
|
||||
HttpResponse,
|
||||
@@ -158,7 +158,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn compat_with_builtin_middleware() {
|
||||
let _ = Condition::new(true, middleware::Compat::noop());
|
||||
let _ = Condition::new(true, middleware::Compat::new(Identity));
|
||||
let _ = Condition::new(true, middleware::Logger::default());
|
||||
let _ = Condition::new(true, middleware::Compress::default());
|
||||
let _ = Condition::new(true, middleware::NormalizePath::trim());
|
||||
|
@@ -2,35 +2,39 @@
|
||||
|
||||
use actix_utils::future::{ready, Ready};
|
||||
|
||||
use crate::dev::{Service, Transform};
|
||||
use crate::dev::{forward_ready, Service, Transform};
|
||||
|
||||
/// A no-op middleware that passes through request and response untouched.
|
||||
pub(crate) struct Noop;
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct Identity;
|
||||
|
||||
impl<S: Service<Req>, Req> Transform<S, Req> for Noop {
|
||||
impl<S: Service<Req>, Req> Transform<S, Req> for Identity {
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type Transform = NoopService<S>;
|
||||
type Transform = IdentityMiddleware<S>;
|
||||
type InitError = ();
|
||||
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
||||
|
||||
#[inline]
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
ready(Ok(NoopService { service }))
|
||||
ready(Ok(IdentityMiddleware { service }))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(crate) struct NoopService<S> {
|
||||
pub struct IdentityMiddleware<S> {
|
||||
service: S,
|
||||
}
|
||||
|
||||
impl<S: Service<Req>, Req> Service<Req> for NoopService<S> {
|
||||
impl<S: Service<Req>, Req> Service<Req> for IdentityMiddleware<S> {
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type Future = S::Future;
|
||||
|
||||
crate::dev::forward_ready!(service);
|
||||
forward_ready!(service);
|
||||
|
||||
#[inline]
|
||||
fn call(&self, req: Req) -> Self::Future {
|
||||
self.service.call(req)
|
||||
}
|
@@ -218,31 +218,27 @@
|
||||
//! [lab_from_fn]: https://docs.rs/actix-web-lab/latest/actix_web_lab/middleware/fn.from_fn.html
|
||||
|
||||
mod compat;
|
||||
#[cfg(feature = "__compress")]
|
||||
mod compress;
|
||||
mod condition;
|
||||
mod default_headers;
|
||||
mod err_handlers;
|
||||
mod identity;
|
||||
mod logger;
|
||||
#[cfg(test)]
|
||||
mod noop;
|
||||
mod normalize;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use self::noop::Noop;
|
||||
#[cfg(feature = "__compress")]
|
||||
pub use self::compress::Compress;
|
||||
pub use self::{
|
||||
compat::Compat,
|
||||
condition::Condition,
|
||||
default_headers::DefaultHeaders,
|
||||
err_handlers::{ErrorHandlerResponse, ErrorHandlers},
|
||||
identity::Identity,
|
||||
logger::Logger,
|
||||
normalize::{NormalizePath, TrailingSlash},
|
||||
};
|
||||
|
||||
#[cfg(feature = "__compress")]
|
||||
mod compress;
|
||||
|
||||
#[cfg(feature = "__compress")]
|
||||
pub use self::compress::Compress;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@@ -64,7 +64,7 @@ compress-gzip = ["actix-http/compress-gzip", "__compress"]
|
||||
compress-zstd = ["actix-http/compress-zstd", "__compress"]
|
||||
|
||||
# Cookie parsing and cookie jar
|
||||
cookies = ["cookie"]
|
||||
cookies = ["dep:cookie"]
|
||||
|
||||
# Use `trust-dns-resolver` crate as DNS resolver
|
||||
trust-dns = ["trust-dns-resolver"]
|
||||
|
Reference in New Issue
Block a user