mirror of https://github.com/fafhrd91/actix-web
Merge branch 'master' into scope_work
This commit is contained in:
commit
16c84c2805
.github/workflows
actix-http
actix-web
|
@ -40,12 +40,12 @@ jobs:
|
||||||
echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append
|
echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||||
|
|
||||||
- name: Install Rust (${{ matrix.version.name }})
|
- name: Install Rust (${{ matrix.version.name }})
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install cargo-hack
|
- name: Install cargo-hack
|
||||||
uses: taiki-e/install-action@v2.24.1
|
uses: taiki-e/install-action@v2.25.9
|
||||||
with:
|
with:
|
||||||
tool: cargo-hack
|
tool: cargo-hack
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
|
|
||||||
- name: Install cargo-hack
|
- name: Install cargo-hack
|
||||||
uses: taiki-e/install-action@v2.24.1
|
uses: taiki-e/install-action@v2.25.9
|
||||||
with:
|
with:
|
||||||
tool: cargo-hack
|
tool: cargo-hack
|
||||||
|
|
||||||
|
@ -103,10 +103,10 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
|
|
||||||
- name: Install nextest
|
- name: Install nextest
|
||||||
uses: taiki-e/install-action@v2.24.1
|
uses: taiki-e/install-action@v2.25.9
|
||||||
with:
|
with:
|
||||||
tool: nextest
|
tool: nextest
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,12 @@ jobs:
|
||||||
echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append
|
echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||||
|
|
||||||
- name: Install Rust (${{ matrix.version.name }})
|
- name: Install Rust (${{ matrix.version.name }})
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.version.version }}
|
toolchain: ${{ matrix.version.version }}
|
||||||
|
|
||||||
- name: Install cargo-hack
|
- name: Install cargo-hack
|
||||||
uses: taiki-e/install-action@v2.24.1
|
uses: taiki-e/install-action@v2.25.9
|
||||||
with:
|
with:
|
||||||
tool: cargo-hack
|
tool: cargo-hack
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust (nightly)
|
- name: Install Rust (nightly)
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
components: llvm-tools-preview
|
components: llvm-tools-preview
|
||||||
|
|
||||||
- name: Install cargo-llvm-cov
|
- name: Install cargo-llvm-cov
|
||||||
uses: taiki-e/install-action@v2.24.1
|
uses: taiki-e/install-action@v2.25.9
|
||||||
with:
|
with:
|
||||||
tool: cargo-llvm-cov
|
tool: cargo-llvm-cov
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,13 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
- name: Install Rust (nightly)
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
- name: Check with rustfmt
|
- name: Check with Rustfmt
|
||||||
run: cargo fmt --all -- --check
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
|
@ -35,7 +36,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
components: clippy
|
components: clippy
|
||||||
|
|
||||||
|
@ -53,7 +54,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
- name: Install Rust (nightly)
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
components: rust-docs
|
components: rust-docs
|
||||||
|
@ -66,21 +68,25 @@ jobs:
|
||||||
public-api-diff:
|
public-api-diff:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout main branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.base_ref }}
|
ref: ${{ github.base_ref }}
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout PR branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
- name: Install Rust
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly-2023-08-25
|
toolchain: nightly-2023-08-25
|
||||||
|
|
||||||
- uses: taiki-e/cache-cargo-install-action@v1.3.0
|
- name: Install cargo-public-api
|
||||||
|
uses: taiki-e/install-action@v2.24.1
|
||||||
with:
|
with:
|
||||||
tool: cargo-public-api
|
tool: cargo-public-api
|
||||||
|
|
||||||
- name: generate API diff
|
- name: Generate API diff
|
||||||
run: |
|
run: |
|
||||||
for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do
|
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" diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }}
|
||||||
|
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1.6.0
|
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ tokio-util = { version = "0.7", features = ["io", "codec"] }
|
||||||
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
|
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
|
||||||
|
|
||||||
# http2
|
# http2
|
||||||
h2 = { version = "0.3.17", optional = true }
|
h2 = { version = "0.3.24", optional = true }
|
||||||
|
|
||||||
# websockets
|
# websockets
|
||||||
local-channel = { version = "0.1", optional = true }
|
local-channel = { version = "0.1", optional = true }
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub struct RequestHead {
|
||||||
pub version: Version,
|
pub version: Version,
|
||||||
pub headers: HeaderMap,
|
pub headers: HeaderMap,
|
||||||
|
|
||||||
/// Will only be None when called in unit tests unless [`TestRequest::peer_addr`] is used.
|
/// Will only be None when called in unit tests unless set manually.
|
||||||
pub peer_addr: Option<net::SocketAddr>,
|
pub peer_addr: Option<net::SocketAddr>,
|
||||||
|
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
|
|
|
@ -372,13 +372,13 @@ You may need to review the [guidance on shared mutable state](https://docs.rs/ac
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
- App::new()
|
- App::new()
|
||||||
- .data(MyState::default())
|
- .data(MyState::default())
|
||||||
- .service(hander)
|
- .service(handler)
|
||||||
|
|
||||||
+ let my_state: Data<MyState> = Data::new(MyState::default());
|
+ let my_state: Data<MyState> = Data::new(MyState::default());
|
||||||
+
|
+
|
||||||
+ App::new()
|
+ App::new()
|
||||||
+ .app_data(my_state)
|
+ .app_data(my_state)
|
||||||
+ .service(hander)
|
+ .service(handler)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,8 @@ where
|
||||||
///
|
///
|
||||||
/// Data items are constructed during application initialization, before the server starts
|
/// Data items are constructed during application initialization, before the server starts
|
||||||
/// accepting requests.
|
/// accepting requests.
|
||||||
|
///
|
||||||
|
/// The returned data value `D` is wrapped as [`Data<D>`].
|
||||||
pub fn data_factory<F, Out, D, E>(mut self, data: F) -> Self
|
pub fn data_factory<F, Out, D, E>(mut self, data: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn() -> Out + 'static,
|
F: Fn() -> Out + 'static,
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub(crate) type FnDataFactory =
|
||||||
/// HttpResponse::Ok()
|
/// HttpResponse::Ok()
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// /// Alteratively, use the `HttpRequest::app_data` method to access data in a handler.
|
/// /// Alternatively, use the `HttpRequest::app_data` method to access data in a handler.
|
||||||
/// async fn index_alt(req: HttpRequest) -> impl Responder {
|
/// async fn index_alt(req: HttpRequest) -> impl Responder {
|
||||||
/// let data = req.app_data::<Data<Mutex<MyData>>>().unwrap();
|
/// let data = req.app_data::<Data<Mutex<MyData>>>().unwrap();
|
||||||
/// let mut my_data = data.lock().unwrap();
|
/// let mut my_data = data.lock().unwrap();
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::http::header::Accept;
|
||||||
pub struct Acceptable {
|
pub struct Acceptable {
|
||||||
mime: mime::Mime,
|
mime: mime::Mime,
|
||||||
|
|
||||||
/// Wether to match `*/*` mime type.
|
/// Whether to match `*/*` mime type.
|
||||||
///
|
///
|
||||||
/// Defaults to false because it's not very useful otherwise.
|
/// Defaults to false because it's not very useful otherwise.
|
||||||
match_star_star: bool,
|
match_star_star: bool,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use actix_http::{header, uri::Uri, RequestHead};
|
||||||
|
|
||||||
use super::{Guard, GuardContext};
|
use super::{Guard, GuardContext};
|
||||||
|
|
||||||
/// Creates a guard that matches requests targetting a specific host.
|
/// Creates a guard that matches requests targeting a specific host.
|
||||||
///
|
///
|
||||||
/// # Matching Host
|
/// # Matching Host
|
||||||
/// This guard will:
|
/// This guard will:
|
||||||
|
|
Loading…
Reference in New Issue