mirror of https://github.com/fafhrd91/actix-web
Merge remote-tracking branch 'origin/master' into accept-encoding
This commit is contained in:
commit
a53479eee6
|
@ -5,6 +5,93 @@ on:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build_and_test_nightly:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu }
|
||||||
|
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
|
||||||
|
- { name: Windows, os: windows-2022, triple: x86_64-pc-windows-msvc }
|
||||||
|
version:
|
||||||
|
- nightly
|
||||||
|
|
||||||
|
name: ${{ matrix.target.name }} / ${{ matrix.version }}
|
||||||
|
runs-on: ${{ matrix.target.os }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
CI: 1
|
||||||
|
CARGO_INCREMENTAL: 0
|
||||||
|
VCPKGRS_DYNAMIC: 1
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# install OpenSSL on Windows
|
||||||
|
# TODO: GitHub actions docs state that OpenSSL is
|
||||||
|
# already installed on these Windows machines somewhere
|
||||||
|
- name: Set vcpkg root
|
||||||
|
if: matrix.target.triple == 'x86_64-pc-windows-msvc'
|
||||||
|
run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||||
|
- name: Install OpenSSL
|
||||||
|
if: matrix.target.triple == 'x86_64-pc-windows-msvc'
|
||||||
|
run: vcpkg install openssl:x64-windows
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-${{ matrix.target.triple }}
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Generate Cargo.lock
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with: { command: generate-lockfile }
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: Swatinem/rust-cache@v1.2.0
|
||||||
|
|
||||||
|
- name: Install cargo-hack
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: install
|
||||||
|
args: cargo-hack
|
||||||
|
|
||||||
|
- name: check minimal
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with: { command: ci-check-min }
|
||||||
|
|
||||||
|
- name: check default
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with: { command: ci-check-default }
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
timeout-minutes: 60
|
||||||
|
run: |
|
||||||
|
cargo test --lib --tests -p=actix-router --all-features
|
||||||
|
cargo test --lib --tests -p=actix-http --all-features
|
||||||
|
cargo test --lib --tests -p=actix-web --features=rustls,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls
|
||||||
|
cargo test --lib --tests -p=actix-web-codegen --all-features
|
||||||
|
cargo test --lib --tests -p=awc --all-features
|
||||||
|
cargo test --lib --tests -p=actix-http-test --all-features
|
||||||
|
cargo test --lib --tests -p=actix-test --all-features
|
||||||
|
cargo test --lib --tests -p=actix-files
|
||||||
|
cargo test --lib --tests -p=actix-multipart --all-features
|
||||||
|
cargo test --lib --tests -p=actix-web-actors --all-features
|
||||||
|
|
||||||
|
- name: tests (io-uring)
|
||||||
|
if: matrix.target.os == 'ubuntu-latest'
|
||||||
|
timeout-minutes: 60
|
||||||
|
run: >
|
||||||
|
sudo bash -c "ulimit -Sl 512
|
||||||
|
&& ulimit -Hl 512
|
||||||
|
&& PATH=$PATH:/usr/share/rust/.cargo/bin
|
||||||
|
&& RUSTUP_TOOLCHAIN=${{ matrix.version }} cargo test --lib --tests -p=actix-files --all-features"
|
||||||
|
|
||||||
|
- name: Clear the cargo caches
|
||||||
|
run: |
|
||||||
|
cargo install cargo-cache --version 0.6.3 --no-default-features --features ci-autoclean
|
||||||
|
cargo-cache
|
||||||
|
|
||||||
ci_feature_powerset_check:
|
ci_feature_powerset_check:
|
||||||
name: Verify Feature Combinations
|
name: Verify Feature Combinations
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -16,9 +16,8 @@ jobs:
|
||||||
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
|
- { name: macOS, os: macos-latest, triple: x86_64-apple-darwin }
|
||||||
- { name: Windows, os: windows-2022, triple: x86_64-pc-windows-msvc }
|
- { name: Windows, os: windows-2022, triple: x86_64-pc-windows-msvc }
|
||||||
version:
|
version:
|
||||||
- 1.52.0 # MSRV
|
- 1.54.0 # MSRV
|
||||||
- stable
|
- stable
|
||||||
- nightly
|
|
||||||
|
|
||||||
name: ${{ matrix.target.name }} / ${{ matrix.version }}
|
name: ${{ matrix.target.name }} / ${{ matrix.version }}
|
||||||
runs-on: ${{ matrix.target.os }}
|
runs-on: ${{ matrix.target.os }}
|
||||||
|
|
17
CHANGES.md
17
CHANGES.md
|
@ -1,6 +1,21 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
|
||||||
|
|
||||||
|
## 4.0.0-beta.18 - 2021-12-29
|
||||||
|
### Changed
|
||||||
|
- Update `cookie` dependency (re-exported) to `0.16`. [#2555]
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- `cookie` upgrade addresses [`RUSTSEC-2020-0071`].
|
||||||
|
|
||||||
|
[#2555]: https://github.com/actix/actix-web/pull/2555
|
||||||
|
[`RUSTSEC-2020-0071`]: https://rustsec.org/advisories/RUSTSEC-2020-0071.html
|
||||||
|
|
||||||
|
|
||||||
|
## 4.0.0-beta.17 - 2021-12-29
|
||||||
### Added
|
### Added
|
||||||
- `guard::GuardContext` for use with the `Guard` trait. [#2552]
|
- `guard::GuardContext` for use with the `Guard` trait. [#2552]
|
||||||
- `ServiceRequest::guard_ctx` for obtaining a guard context. [#2552]
|
- `ServiceRequest::guard_ctx` for obtaining a guard context. [#2552]
|
||||||
|
@ -10,7 +25,7 @@
|
||||||
### Changed
|
### Changed
|
||||||
- `Guard` trait now receives a `&GuardContext`. [#2552]
|
- `Guard` trait now receives a `&GuardContext`. [#2552]
|
||||||
- `guard::fn_guard` functions now receives a `&GuardContext`. [#2552]
|
- `guard::fn_guard` functions now receives a `&GuardContext`. [#2552]
|
||||||
- Some guards now return `impl Guard` and their concrete types are made private: `guard::{Header}` and all the method guards. [#2552]
|
- Some guards now return `impl Guard` and their concrete types are made private: `guard::Header` and all the method guards. [#2552]
|
||||||
- The `Not` guard is now generic over the type of guard it wraps. [#2552]
|
- The `Not` guard is now generic over the type of guard it wraps. [#2552]
|
||||||
- `AcceptEncoding::preference` now returns `Option<Preference<Encoding>>`. [#2501]
|
- `AcceptEncoding::preference` now returns `Option<Preference<Encoding>>`. [#2501]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-web"
|
name = "actix-web"
|
||||||
version = "4.0.0-beta.16"
|
version = "4.0.0-beta.18"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust"
|
description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust"
|
||||||
keywords = ["actix", "http", "web", "framework", "async"]
|
keywords = ["actix", "http", "web", "framework", "async"]
|
||||||
|
@ -84,7 +84,7 @@ actix-web-codegen = "0.5.0-beta.6"
|
||||||
ahash = "0.7"
|
ahash = "0.7"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
cookie = { version = "0.15", features = ["percent-encode"], optional = true }
|
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures-core = { version = "0.3.7", default-features = false }
|
futures-core = { version = "0.3.7", default-features = false }
|
||||||
|
@ -94,7 +94,6 @@ language-tags = "0.3"
|
||||||
once_cell = "1.5"
|
once_cell = "1.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
paste = "1"
|
|
||||||
pin-project-lite = "0.2.7"
|
pin-project-lite = "0.2.7"
|
||||||
regex = "1.4"
|
regex = "1.4"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
@ -107,7 +106,7 @@ url = "2.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-test = { version = "0.1.0-beta.10", features = ["openssl", "rustls"] }
|
actix-test = { version = "0.1.0-beta.10", features = ["openssl", "rustls"] }
|
||||||
awc = { version = "3.0.0-beta.15", features = ["openssl"] }
|
awc = { version = "3.0.0-beta.17", features = ["openssl"] }
|
||||||
|
|
||||||
brotli2 = "0.3.2"
|
brotli2 = "0.3.2"
|
||||||
criterion = { version = "0.3", features = ["html_reports"] }
|
criterion = { version = "0.3", features = ["html_reports"] }
|
||||||
|
|
10
README.md
10
README.md
|
@ -6,12 +6,12 @@
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-web)
|
[](https://crates.io/crates/actix-web)
|
||||||
[](https://docs.rs/actix-web/4.0.0-beta.16)
|
[](https://docs.rs/actix-web/4.0.0-beta.18)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
[](https://deps.rs/crate/actix-web/4.0.0-beta.16)
|
[](https://deps.rs/crate/actix-web/4.0.0-beta.18)
|
||||||
<br />
|
<br />
|
||||||
[](https://github.com/actix/actix-web/actions)
|
[](https://github.com/actix/actix-web/actions/workflows/ci.yml)
|
||||||
[](https://codecov.io/gh/actix/actix-web)
|
[](https://codecov.io/gh/actix/actix-web)
|
||||||

|

|
||||||
[](https://discord.gg/NWpN5mmg3x)
|
[](https://discord.gg/NWpN5mmg3x)
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
- SSL support using OpenSSL or Rustls
|
- SSL support using OpenSSL or Rustls
|
||||||
- Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
|
- Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
|
||||||
- Includes an async [HTTP client](https://docs.rs/awc/)
|
- Includes an async [HTTP client](https://docs.rs/awc/)
|
||||||
- Runs on stable Rust 1.52+
|
- Runs on stable Rust 1.54+
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
|
## 0.6.0-beta.12 - 2021-12-29
|
||||||
|
- No significant changes since `0.6.0-beta.11`.
|
||||||
|
|
||||||
|
|
||||||
## 0.6.0-beta.11 - 2021-12-27
|
## 0.6.0-beta.11 - 2021-12-27
|
||||||
* No significant changes since `0.6.0-beta.10`.
|
- No significant changes since `0.6.0-beta.10`.
|
||||||
|
|
||||||
|
|
||||||
## 0.6.0-beta.10 - 2021-12-11
|
## 0.6.0-beta.10 - 2021-12-11
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-files"
|
name = "actix-files"
|
||||||
version = "0.6.0-beta.11"
|
version = "0.6.0-beta.12"
|
||||||
authors = [
|
authors = [
|
||||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||||
"fakeshadow <24548779@qq.com>",
|
"fakeshadow <24548779@qq.com>",
|
||||||
|
@ -25,7 +25,7 @@ experimental-io-uring = ["actix-web/experimental-io-uring", "tokio-uring"]
|
||||||
actix-http = "3.0.0-beta.17"
|
actix-http = "3.0.0-beta.17"
|
||||||
actix-service = "2"
|
actix-service = "2"
|
||||||
actix-utils = "3"
|
actix-utils = "3"
|
||||||
actix-web = { version = "4.0.0-beta.16", default-features = false }
|
actix-web = { version = "4.0.0-beta.18", default-features = false }
|
||||||
|
|
||||||
askama_escape = "0.10"
|
askama_escape = "0.10"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
|
@ -44,4 +44,4 @@ tokio-uring = { version = "0.1", optional = true }
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2.2"
|
actix-rt = "2.2"
|
||||||
actix-test = "0.1.0-beta.10"
|
actix-test = "0.1.0-beta.10"
|
||||||
actix-web = "4.0.0-beta.16"
|
actix-web = "4.0.0-beta.18"
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
> Static file serving for Actix Web
|
> Static file serving for Actix Web
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-files)
|
[](https://crates.io/crates/actix-files)
|
||||||
[](https://docs.rs/actix-files/0.6.0-beta.11)
|
[](https://docs.rs/actix-files/0.6.0-beta.12)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
<br />
|
<br />
|
||||||
[](https://deps.rs/crate/actix-files/0.6.0-beta.11)
|
[](https://deps.rs/crate/actix-files/0.6.0-beta.12)
|
||||||
[](https://crates.io/crates/actix-files)
|
[](https://crates.io/crates/actix-files)
|
||||||
[](https://discord.gg/NWpN5mmg3x)
|
[](https://discord.gg/NWpN5mmg3x)
|
||||||
|
|
||||||
|
@ -15,4 +15,4 @@
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/actix-files/)
|
- [API Documentation](https://docs.rs/actix-files/)
|
||||||
- [Example Project](https://github.com/actix/examples/tree/master/basics/static_index)
|
- [Example Project](https://github.com/actix/examples/tree/master/basics/static_index)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
## 3.0.0-beta.10 - 2021-12-27
|
## 3.0.0-beta.10 - 2021-12-27
|
||||||
|
|
|
@ -35,7 +35,7 @@ actix-tls = "3.0.0"
|
||||||
actix-utils = "3.0.0"
|
actix-utils = "3.0.0"
|
||||||
actix-rt = "2.2"
|
actix-rt = "2.2"
|
||||||
actix-server = "2.0.0-rc.2"
|
actix-server = "2.0.0-rc.2"
|
||||||
awc = { version = "3.0.0-beta.15", default-features = false }
|
awc = { version = "3.0.0-beta.17", default-features = false }
|
||||||
|
|
||||||
base64 = "0.13"
|
base64 = "0.13"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
|
@ -51,5 +51,5 @@ tls-openssl = { version = "0.10.9", package = "openssl", optional = true }
|
||||||
tokio = { version = "1.8.4", features = ["sync"] }
|
tokio = { version = "1.8.4", features = ["sync"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-web = { version = "4.0.0-beta.16", default-features = false, features = ["cookies"] }
|
actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["cookies"] }
|
||||||
actix-http = "3.0.0-beta.17"
|
actix-http = "3.0.0-beta.17"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-http-test)
|
[](https://crates.io/crates/actix-http-test)
|
||||||
[](https://docs.rs/actix-http-test/3.0.0-beta.10)
|
[](https://docs.rs/actix-http-test/3.0.0-beta.10)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
<br>
|
<br>
|
||||||
[](https://deps.rs/crate/actix-http-test/3.0.0-beta.10)
|
[](https://deps.rs/crate/actix-http-test/3.0.0-beta.10)
|
||||||
|
@ -14,4 +14,4 @@
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/actix-http-test)
|
- [API Documentation](https://docs.rs/actix-http-test)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
### Changed
|
### Changed
|
||||||
- `Quality::MIN` is now the smallest non-zero value. [#2501]
|
- `Quality::MIN` is now the smallest non-zero value. [#2501]
|
||||||
- `QualityItem::min` has different semantics due to the `QualityItem::MIN` change. [#2501]
|
- `QualityItem::min` has different semantics due to the `QualityItem::MIN` change. [#2501]
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
[#2501]: https://github.com/actix/actix-web/pull/2501
|
[#2501]: https://github.com/actix/actix-web/pull/2501
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ zstd = { version = "0.9", optional = true }
|
||||||
actix-http-test = { version = "3.0.0-beta.10", features = ["openssl"] }
|
actix-http-test = { version = "3.0.0-beta.10", features = ["openssl"] }
|
||||||
actix-server = "2.0.0-rc.2"
|
actix-server = "2.0.0-rc.2"
|
||||||
actix-tls = { version = "3.0.0", features = ["openssl"] }
|
actix-tls = { version = "3.0.0", features = ["openssl"] }
|
||||||
actix-web = "4.0.0-beta.16"
|
actix-web = "4.0.0-beta.18"
|
||||||
|
|
||||||
async-stream = "0.3"
|
async-stream = "0.3"
|
||||||
criterion = { version = "0.3", features = ["html_reports"] }
|
criterion = { version = "0.3", features = ["html_reports"] }
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-http)
|
[](https://crates.io/crates/actix-http)
|
||||||
[](https://docs.rs/actix-http/3.0.0-beta.17)
|
[](https://docs.rs/actix-http/3.0.0-beta.17)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
<br />
|
<br />
|
||||||
[](https://deps.rs/crate/actix-http/3.0.0-beta.17)
|
[](https://deps.rs/crate/actix-http/3.0.0-beta.17)
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/actix-http)
|
- [API Documentation](https://docs.rs/actix-http)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
## 0.4.0-beta.11 - 2021-12-27
|
## 0.4.0-beta.11 - 2021-12-27
|
||||||
* No significant changes since `0.4.0-beta.10`.
|
- No significant changes since `0.4.0-beta.10`.
|
||||||
|
|
||||||
|
|
||||||
## 0.4.0-beta.10 - 2021-12-11
|
## 0.4.0-beta.10 - 2021-12-11
|
||||||
|
|
|
@ -15,7 +15,7 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-utils = "3.0.0"
|
actix-utils = "3.0.0"
|
||||||
actix-web = { version = "4.0.0-beta.16", default-features = false }
|
actix-web = { version = "4.0.0-beta.18", default-features = false }
|
||||||
|
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-multipart)
|
[](https://crates.io/crates/actix-multipart)
|
||||||
[](https://docs.rs/actix-multipart/0.4.0-beta.11)
|
[](https://docs.rs/actix-multipart/0.4.0-beta.11)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
<br />
|
<br />
|
||||||
[](https://deps.rs/crate/actix-multipart/0.4.0-beta.11)
|
[](https://deps.rs/crate/actix-multipart/0.4.0-beta.11)
|
||||||
|
@ -14,4 +14,4 @@
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/actix-multipart)
|
- [API Documentation](https://docs.rs/actix-multipart)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
## 0.5.0-beta.3 - 2021-12-17
|
## 0.5.0-beta.3 - 2021-12-17
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
## 0.1.0-beta.10 - 2021-12-27
|
## 0.1.0-beta.10 - 2021-12-27
|
||||||
* No significant changes since `0.1.0-beta.9`.
|
- No significant changes since `0.1.0-beta.9`.
|
||||||
|
|
||||||
|
|
||||||
## 0.1.0-beta.9 - 2021-12-17
|
## 0.1.0-beta.9 - 2021-12-17
|
||||||
|
|
|
@ -34,8 +34,8 @@ actix-http-test = "3.0.0-beta.10"
|
||||||
actix-rt = "2.1"
|
actix-rt = "2.1"
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
actix-utils = "3.0.0"
|
actix-utils = "3.0.0"
|
||||||
actix-web = { version = "4.0.0-beta.16", default-features = false, features = ["cookies"] }
|
actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["cookies"] }
|
||||||
awc = { version = "3.0.0-beta.15", default-features = false, features = ["cookies"] }
|
awc = { version = "3.0.0-beta.17", default-features = false, features = ["cookies"] }
|
||||||
|
|
||||||
futures-core = { version = "0.3.7", default-features = false, features = ["std"] }
|
futures-core = { version = "0.3.7", default-features = false, features = ["std"] }
|
||||||
futures-util = { version = "0.3.7", default-features = false, features = [] }
|
futures-util = { version = "0.3.7", default-features = false, features = [] }
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
## 4.0.0-beta.9 - 2021-12-27
|
## 4.0.0-beta.9 - 2021-12-27
|
||||||
* No significant changes since `4.0.0-beta.8`.
|
- No significant changes since `4.0.0-beta.8`.
|
||||||
|
|
||||||
|
|
||||||
## 4.0.0-beta.8 - 2021-12-11
|
## 4.0.0-beta.8 - 2021-12-11
|
||||||
|
|
|
@ -17,7 +17,7 @@ path = "src/lib.rs"
|
||||||
actix = { version = "0.12.0", default-features = false }
|
actix = { version = "0.12.0", default-features = false }
|
||||||
actix-codec = "0.4.1"
|
actix-codec = "0.4.1"
|
||||||
actix-http = "3.0.0-beta.17"
|
actix-http = "3.0.0-beta.17"
|
||||||
actix-web = { version = "4.0.0-beta.16", default-features = false }
|
actix-web = { version = "4.0.0-beta.18", default-features = false }
|
||||||
|
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
bytestring = "1"
|
bytestring = "1"
|
||||||
|
@ -28,7 +28,7 @@ tokio = { version = "1.8.4", features = ["sync"] }
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2.2"
|
actix-rt = "2.2"
|
||||||
actix-test = "0.1.0-beta.10"
|
actix-test = "0.1.0-beta.10"
|
||||||
awc = { version = "3.0.0-beta.15", default-features = false }
|
awc = { version = "3.0.0-beta.17", default-features = false }
|
||||||
|
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-web-actors)
|
[](https://crates.io/crates/actix-web-actors)
|
||||||
[](https://docs.rs/actix-web-actors/4.0.0-beta.9)
|
[](https://docs.rs/actix-web-actors/4.0.0-beta.9)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
<br />
|
<br />
|
||||||
[](https://deps.rs/crate/actix-web-actors/4.0.0-beta.9)
|
[](https://deps.rs/crate/actix-web-actors/4.0.0-beta.9)
|
||||||
|
@ -14,4 +14,4 @@
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/actix-web-actors)
|
- [API Documentation](https://docs.rs/actix-web-actors)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
- Minimum supported Rust version (MSRV) is now 1.54.
|
||||||
|
|
||||||
|
|
||||||
## 0.5.0-beta.6 - 2021-12-11
|
## 0.5.0-beta.6 - 2021-12-11
|
||||||
|
|
|
@ -25,7 +25,7 @@ actix-macros = "0.2.3"
|
||||||
actix-rt = "2.2"
|
actix-rt = "2.2"
|
||||||
actix-test = "0.1.0-beta.10"
|
actix-test = "0.1.0-beta.10"
|
||||||
actix-utils = "3.0.0"
|
actix-utils = "3.0.0"
|
||||||
actix-web = "4.0.0-beta.16"
|
actix-web = "4.0.0-beta.18"
|
||||||
|
|
||||||
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
||||||
trybuild = "1"
|
trybuild = "1"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-web-codegen)
|
[](https://crates.io/crates/actix-web-codegen)
|
||||||
[](https://docs.rs/actix-web-codegen/0.5.0-beta.6)
|
[](https://docs.rs/actix-web-codegen/0.5.0-beta.6)
|
||||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
[](https://blog.rust-lang.org/2021/05/06/Rust-1.54.0.html)
|
||||||

|

|
||||||
<br />
|
<br />
|
||||||
[](https://deps.rs/crate/actix-web-codegen/0.5.0-beta.6)
|
[](https://deps.rs/crate/actix-web-codegen/0.5.0-beta.6)
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/actix-web-codegen)
|
- [API Documentation](https://docs.rs/actix-web-codegen)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
||||||
## Compile Testing
|
## Compile Testing
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#[rustversion::stable(1.52)] // MSRV
|
#[rustversion::stable(1.54)] // MSRV
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_macros() {
|
fn compile_macros() {
|
||||||
let t = trybuild::TestCases::new();
|
let t = trybuild::TestCases::new();
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
error: The #[route(..)] macro requires at least one `method` attribute
|
error: The #[route(..)] macro requires at least one `method` attribute
|
||||||
--> $DIR/route-missing-method-fail.rs:3:1
|
--> tests/trybuild/route-missing-method-fail.rs:3:1
|
||||||
|
|
|
|
||||||
3 | #[route("/")]
|
3 | #[route("/")]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the attribute macro `route` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0277]: the trait bound `fn() -> impl std::future::Future {index}: HttpServiceFactory` is not satisfied
|
error[E0277]: the trait bound `fn() -> impl std::future::Future {index}: HttpServiceFactory` is not satisfied
|
||||||
--> $DIR/route-missing-method-fail.rs:12:55
|
--> tests/trybuild/route-missing-method-fail.rs:12:55
|
||||||
|
|
|
|
||||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||||
| ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
| ^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl std::future::Future {index}`
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.0-beta.17 - 2021-12-29
|
||||||
|
### Changed
|
||||||
|
- Update `cookie` dependency (re-exported) to `0.16`. [#2555]
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- `cookie` upgrade addresses [`RUSTSEC-2020-0071`].
|
||||||
|
|
||||||
|
[#2555]: https://github.com/actix/actix-web/pull/2555
|
||||||
|
[`RUSTSEC-2020-0071`]: https://rustsec.org/advisories/RUSTSEC-2020-0071.html
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.0-beta.16 - 2021-12-29
|
||||||
- `*::send_json` and `*::send_form` methods now receive `impl Serialize`. [#2553]
|
- `*::send_json` and `*::send_form` methods now receive `impl Serialize`. [#2553]
|
||||||
- `FrozenClientRequest::extra_header` now uses receives an `impl TryIntoHeaderPair`. [#2553]
|
- `FrozenClientRequest::extra_header` now uses receives an `impl TryIntoHeaderPair`. [#2553]
|
||||||
- Remove unnecessary `Unpin` bounds on `*::send_stream`. [#2553]
|
- Remove unnecessary `Unpin` bounds on `*::send_stream`. [#2553]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "awc"
|
name = "awc"
|
||||||
version = "3.0.0-beta.15"
|
version = "3.0.0-beta.17"
|
||||||
authors = [
|
authors = [
|
||||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||||
"fakeshadow <24548779@qq.com>",
|
"fakeshadow <24548779@qq.com>",
|
||||||
|
@ -85,7 +85,7 @@ serde_json = "1.0"
|
||||||
serde_urlencoded = "0.7"
|
serde_urlencoded = "0.7"
|
||||||
tokio = { version = "1.8.4", features = ["sync"] }
|
tokio = { version = "1.8.4", features = ["sync"] }
|
||||||
|
|
||||||
cookie = { version = "0.15", features = ["percent-encode"], optional = true }
|
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
|
||||||
|
|
||||||
tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
|
tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
|
||||||
tls-rustls = { package = "rustls", version = "0.20.0", optional = true, features = ["dangerous_configuration"] }
|
tls-rustls = { package = "rustls", version = "0.20.0", optional = true, features = ["dangerous_configuration"] }
|
||||||
|
@ -99,7 +99,7 @@ actix-server = "2.0.0-rc.2"
|
||||||
actix-test = { version = "0.1.0-beta.10", features = ["openssl", "rustls"] }
|
actix-test = { version = "0.1.0-beta.10", features = ["openssl", "rustls"] }
|
||||||
actix-tls = { version = "3.0.0", features = ["openssl", "rustls"] }
|
actix-tls = { version = "3.0.0", features = ["openssl", "rustls"] }
|
||||||
actix-utils = "3.0.0"
|
actix-utils = "3.0.0"
|
||||||
actix-web = { version = "4.0.0-beta.16", features = ["openssl"] }
|
actix-web = { version = "4.0.0-beta.18", features = ["openssl"] }
|
||||||
|
|
||||||
brotli2 = "0.3.2"
|
brotli2 = "0.3.2"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
|
|
|
@ -3,16 +3,16 @@
|
||||||
> Async HTTP and WebSocket client library.
|
> Async HTTP and WebSocket client library.
|
||||||
|
|
||||||
[](https://crates.io/crates/awc)
|
[](https://crates.io/crates/awc)
|
||||||
[](https://docs.rs/awc/3.0.0-beta.15)
|
[](https://docs.rs/awc/3.0.0-beta.17)
|
||||||

|

|
||||||
[](https://deps.rs/crate/awc/3.0.0-beta.15)
|
[](https://deps.rs/crate/awc/3.0.0-beta.17)
|
||||||
[](https://discord.gg/NWpN5mmg3x)
|
[](https://discord.gg/NWpN5mmg3x)
|
||||||
|
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
- [API Documentation](https://docs.rs/awc)
|
- [API Documentation](https://docs.rs/awc)
|
||||||
- [Example Project](https://github.com/actix/examples/tree/HEAD/security/awc_https)
|
- [Example Project](https://github.com/actix/examples/tree/HEAD/security/awc_https)
|
||||||
- Minimum Supported Rust Version (MSRV): 1.52
|
- Minimum Supported Rust Version (MSRV): 1.54
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
msrv = "1.52"
|
msrv = "1.54"
|
||||||
|
|
|
@ -40,7 +40,7 @@ cat "$CHANGELOG_FILE" |
|
||||||
|
|
||||||
# if word count of changelog chunk is 0 then insert filler changelog chunk
|
# if word count of changelog chunk is 0 then insert filler changelog chunk
|
||||||
if [ "$(wc -w "$CHANGE_CHUNK_FILE" | awk '{ print $1 }')" = "0" ]; then
|
if [ "$(wc -w "$CHANGE_CHUNK_FILE" | awk '{ print $1 }')" = "0" ]; then
|
||||||
echo "* No significant changes since \`$CURRENT_VERSION\`." >"$CHANGE_CHUNK_FILE"
|
echo "- No significant changes since \`$CURRENT_VERSION\`." >"$CHANGE_CHUNK_FILE"
|
||||||
echo >>"$CHANGE_CHUNK_FILE"
|
echo >>"$CHANGE_CHUNK_FILE"
|
||||||
echo >>"$CHANGE_CHUNK_FILE"
|
echo >>"$CHANGE_CHUNK_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -109,6 +109,7 @@ impl<T> App<T> {
|
||||||
/// .route("/", web::get().to(handler))
|
/// .route("/", web::get().to(handler))
|
||||||
/// })
|
/// })
|
||||||
/// ```
|
/// ```
|
||||||
|
#[doc(alias = "manage")]
|
||||||
pub fn app_data<U: 'static>(mut self, ext: U) -> Self {
|
pub fn app_data<U: 'static>(mut self, ext: U) -> Self {
|
||||||
self.extensions.insert(ext);
|
self.extensions.insert(ext);
|
||||||
self
|
self
|
||||||
|
|
45
src/data.rs
45
src/data.rs
|
@ -19,23 +19,32 @@ pub(crate) trait DataFactory {
|
||||||
pub(crate) type FnDataFactory =
|
pub(crate) type FnDataFactory =
|
||||||
Box<dyn Fn() -> LocalBoxFuture<'static, Result<Box<dyn DataFactory>, ()>>>;
|
Box<dyn Fn() -> LocalBoxFuture<'static, Result<Box<dyn DataFactory>, ()>>>;
|
||||||
|
|
||||||
/// Application data.
|
/// Application data wrapper and extractor.
|
||||||
///
|
///
|
||||||
/// Application level data is a piece of arbitrary data attached to the app, scope, or resource.
|
/// # Setting Data
|
||||||
/// Application data is available to all routes and can be added during the application
|
/// Data is set using the `app_data` methods on `App`, `Scope`, and `Resource`. If data is wrapped
|
||||||
/// configuration process via `App::data()`.
|
/// in this `Data` type for those calls, it can be used as an extractor.
|
||||||
///
|
///
|
||||||
/// Application data can be accessed by using `Data<T>` extractor where `T` is data type.
|
/// Note that `Data` should be constructed _outside_ the `HttpServer::new` closure if shared,
|
||||||
|
/// potentially mutable state is desired. `Data` is cheap to clone; internally, it uses an `Arc`.
|
||||||
///
|
///
|
||||||
/// **Note**: HTTP server accepts an application factory rather than an application instance. HTTP
|
/// See also [`App::app_data`](crate::App::app_data), [`Scope::app_data`](crate::Scope::app_data),
|
||||||
/// server constructs an application instance for each thread, thus application data must be
|
/// and [`Resource::app_data`](crate::Resource::app_data).
|
||||||
/// constructed multiple times. If you want to share data between different threads, a shareable
|
///
|
||||||
/// object should be used, e.g. `Send + Sync`. Application data does not need to be `Send`
|
/// # Extracting `Data`
|
||||||
/// or `Sync`. Internally `Data` contains an `Arc`.
|
/// Since the Actix Web router layers application data, the returned object will reference the
|
||||||
|
/// "closest" instance of the type. For example, if an `App` stores a `u32`, a nested `Scope`
|
||||||
|
/// also stores a `u32`, and the delegated request handler falls within that `Scope`, then
|
||||||
|
/// extracting a `web::<Data<u32>>` for that handler will return the `Scope`'s instance.
|
||||||
|
/// However, using the same router set up and a request that does not get captured by the `Scope`,
|
||||||
|
/// `web::<Data<u32>>` would return the `App`'s instance.
|
||||||
///
|
///
|
||||||
/// If route data is not set for a handler, using `Data<T>` extractor would cause a `500 Internal
|
/// If route data is not set for a handler, using `Data<T>` extractor would cause a `500 Internal
|
||||||
/// Server Error` response.
|
/// Server Error` response.
|
||||||
///
|
///
|
||||||
|
/// See also [`HttpRequest::app_data`]
|
||||||
|
/// and [`ServiceRequest::app_data`](crate::dev::ServiceRequest::app_data).
|
||||||
|
///
|
||||||
/// # Unsized Data
|
/// # Unsized Data
|
||||||
/// For types that are unsized, most commonly `dyn T`, `Data` can wrap these types by first
|
/// For types that are unsized, most commonly `dyn T`, `Data` can wrap these types by first
|
||||||
/// constructing an `Arc<dyn T>` and using the `From` implementation to convert it.
|
/// constructing an `Arc<dyn T>` and using the `From` implementation to convert it.
|
||||||
|
@ -79,6 +88,7 @@ pub(crate) type FnDataFactory =
|
||||||
/// .route("/index.html", web::get().to(index))
|
/// .route("/index.html", web::get().to(index))
|
||||||
/// .route("/index-alt.html", web::get().to(index_alt));
|
/// .route("/index-alt.html", web::get().to(index_alt));
|
||||||
/// ```
|
/// ```
|
||||||
|
#[doc(alias = "state")]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Data<T: ?Sized>(Arc<T>);
|
pub struct Data<T: ?Sized>(Arc<T>);
|
||||||
|
|
||||||
|
@ -90,12 +100,12 @@ impl<T> Data<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ?Sized> Data<T> {
|
impl<T: ?Sized> Data<T> {
|
||||||
/// Get reference to inner app data.
|
/// Returns reference to inner `T`.
|
||||||
pub fn get_ref(&self) -> &T {
|
pub fn get_ref(&self) -> &T {
|
||||||
self.0.as_ref()
|
self.0.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert to the internal Arc<T>
|
/// Unwraps to the internal `Arc<T>`
|
||||||
pub fn into_inner(self) -> Arc<T> {
|
pub fn into_inner(self) -> Arc<T> {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
@ -143,13 +153,16 @@ impl<T: ?Sized + 'static> FromRequest for Data<T> {
|
||||||
ok(st.clone())
|
ok(st.clone())
|
||||||
} else {
|
} else {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"Failed to construct App-level Data extractor. \
|
"Failed to extract `Data<{}>` for `{}` handler. For the Data extractor to work \
|
||||||
Request path: {:?} (type: {})",
|
correctly, wrap the data with `Data::new()` and pass it to `App::app_data()`. \
|
||||||
req.path(),
|
Ensure that types align in both the set and retrieve calls.",
|
||||||
type_name::<T>(),
|
type_name::<T>(),
|
||||||
|
req.match_name().unwrap_or_else(|| req.path())
|
||||||
);
|
);
|
||||||
|
|
||||||
err(ErrorInternalServerError(
|
err(ErrorInternalServerError(
|
||||||
"App data is not configured, to configure construct it with web::Data::new() and pass it to App::app_data()",
|
"Requested application data is not configured correctly. \
|
||||||
|
View/enable debug logs for more details.",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,7 @@ where
|
||||||
|
|
||||||
macro_rules! error_helper {
|
macro_rules! error_helper {
|
||||||
($name:ident, $status:ident) => {
|
($name:ident, $status:ident) => {
|
||||||
paste::paste! {
|
#[doc = concat!("Helper function that wraps any error and generates a `", stringify!($status), "` response.")]
|
||||||
#[doc = "Helper function that wraps any error and generates a `" $status "` response."]
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn $name<T>(err: T) -> Error
|
pub fn $name<T>(err: T) -> Error
|
||||||
where
|
where
|
||||||
|
@ -127,7 +126,6 @@ macro_rules! error_helper {
|
||||||
{
|
{
|
||||||
InternalError::new(err, StatusCode::$status).into()
|
InternalError::new(err, StatusCode::$status).into()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,23 +270,21 @@ impl Guard for MethodGuard {
|
||||||
|
|
||||||
macro_rules! method_guard {
|
macro_rules! method_guard {
|
||||||
($method_fn:ident, $method_const:ident) => {
|
($method_fn:ident, $method_const:ident) => {
|
||||||
paste::paste! {
|
#[doc = concat!("Creates a guard that matches the `", stringify!($method_const), "` request method.")]
|
||||||
#[doc = " Creates a guard that matches the `" $method_const "` request method."]
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
#[doc = " The route in this example will only respond to `" $method_const "` requests."]
|
#[doc = concat!("The route in this example will only respond to `", stringify!($method_const), "` requests.")]
|
||||||
/// ```
|
/// ```
|
||||||
/// use actix_web::{guard, web, HttpResponse};
|
/// use actix_web::{guard, web, HttpResponse};
|
||||||
///
|
///
|
||||||
/// web::route()
|
/// web::route()
|
||||||
#[doc = " .guard(guard::" $method_fn "())"]
|
#[doc = concat!(" .guard(guard::", stringify!($method_fn), "())")]
|
||||||
/// .to(|| HttpResponse::Ok());
|
/// .to(|| HttpResponse::Ok());
|
||||||
/// ```
|
/// ```
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn $method_fn() -> impl Guard {
|
pub fn $method_fn() -> impl Guard {
|
||||||
MethodGuard(HttpMethod::$method_const)
|
MethodGuard(HttpMethod::$method_const)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
//! * SSL support using OpenSSL or Rustls
|
//! * SSL support using OpenSSL or Rustls
|
||||||
//! * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
|
//! * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
|
||||||
//! * Includes an async [HTTP client](https://docs.rs/awc/)
|
//! * Includes an async [HTTP client](https://docs.rs/awc/)
|
||||||
//! * Runs on stable Rust 1.52+
|
//! * Runs on stable Rust 1.54+
|
||||||
//!
|
//!
|
||||||
//! # Crate Features
|
//! # Crate Features
|
||||||
//! * `cookies` - cookies support (enabled by default)
|
//! * `cookies` - cookies support (enabled by default)
|
||||||
|
|
|
@ -266,14 +266,34 @@ impl HttpRequest {
|
||||||
self.app_state().config()
|
self.app_state().config()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an application data object stored with `App::data` or `App::app_data`
|
/// Retrieves a piece of application state.
|
||||||
/// methods during application configuration.
|
|
||||||
///
|
///
|
||||||
/// If `App::data` was used to store object, use `Data<T>`:
|
/// Extracts any object stored with [`App::app_data()`](crate::App::app_data) (or the
|
||||||
|
/// counterpart methods on [`Scope`](crate::Scope::app_data) and
|
||||||
|
/// [`Resource`](crate::Resource::app_data)) during application configuration.
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// Since the Actix Web router layers application data, the returned object will reference the
|
||||||
/// let opt_t = req.app_data::<Data<T>>();
|
/// "closest" instance of the type. For example, if an `App` stores a `u32`, a nested `Scope`
|
||||||
|
/// also stores a `u32`, and the delegated request handler falls within that `Scope`, then
|
||||||
|
/// calling `.app_data::<u32>()` on an `HttpRequest` within that handler will return the
|
||||||
|
/// `Scope`'s instance. However, using the same router set up and a request that does not get
|
||||||
|
/// captured by the `Scope`, `.app_data::<u32>()` would return the `App`'s instance.
|
||||||
|
///
|
||||||
|
/// If the state was stored using the [`Data`] wrapper, then it must also be retrieved using
|
||||||
|
/// this same type.
|
||||||
|
///
|
||||||
|
/// See also the [`Data`] extractor.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
/// ```no_run
|
||||||
|
/// # use actix_web::{test::TestRequest, web::Data};
|
||||||
|
/// # let req = TestRequest::default().to_http_request();
|
||||||
|
/// # type T = u32;
|
||||||
|
/// let opt_t: Option<&Data<T>> = req.app_data::<Data<T>>();
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// [`Data`]: crate::web::Data
|
||||||
|
#[doc(alias = "state")]
|
||||||
pub fn app_data<T: 'static>(&self) -> Option<&T> {
|
pub fn app_data<T: 'static>(&self) -> Option<&T> {
|
||||||
for container in self.inner.app_data.iter().rev() {
|
for container in self.inner.app_data.iter().rev() {
|
||||||
if let Some(data) = container.get::<T>() {
|
if let Some(data) = container.get::<T>() {
|
||||||
|
|
|
@ -195,6 +195,7 @@ where
|
||||||
/// .route(web::get().to(handler))
|
/// .route(web::get().to(handler))
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
|
#[doc(alias = "manage")]
|
||||||
pub fn app_data<U: 'static>(mut self, data: U) -> Self {
|
pub fn app_data<U: 'static>(mut self, data: U) -> Self {
|
||||||
self.app_data
|
self.app_data
|
||||||
.get_or_insert_with(Extensions::new)
|
.get_or_insert_with(Extensions::new)
|
||||||
|
|
|
@ -154,6 +154,7 @@ where
|
||||||
/// .route("/", web::get().to(handler))
|
/// .route("/", web::get().to(handler))
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
|
#[doc(alias = "manage")]
|
||||||
pub fn app_data<U: 'static>(mut self, data: U) -> Self {
|
pub fn app_data<U: 'static>(mut self, data: U) -> Self {
|
||||||
self.app_data
|
self.app_data
|
||||||
.get_or_insert_with(Extensions::new)
|
.get_or_insert_with(Extensions::new)
|
||||||
|
|
|
@ -86,24 +86,22 @@ pub fn route() -> Route {
|
||||||
|
|
||||||
macro_rules! method_route {
|
macro_rules! method_route {
|
||||||
($method_fn:ident, $method_const:ident) => {
|
($method_fn:ident, $method_const:ident) => {
|
||||||
paste::paste! {
|
#[doc = concat!(" Creates a new route with `", stringify!($method_const), "` method guard.")]
|
||||||
#[doc = " Creates a new route with `" $method_const "` method guard."]
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
#[doc = " In this example, one `" $method_const " /{project_id}` route is set up:"]
|
#[doc = concat!(" In this example, one `", stringify!($method_const), " /{project_id}` route is set up:")]
|
||||||
/// ```
|
/// ```
|
||||||
/// use actix_web::{web, App, HttpResponse};
|
/// use actix_web::{web, App, HttpResponse};
|
||||||
///
|
///
|
||||||
/// let app = App::new().service(
|
/// let app = App::new().service(
|
||||||
/// web::resource("/{project_id}")
|
/// web::resource("/{project_id}")
|
||||||
#[doc = " .route(web::" $method_fn "().to(|| HttpResponse::Ok()))"]
|
#[doc = concat!(" .route(web::", stringify!($method_fn), "().to(|| HttpResponse::Ok()))")]
|
||||||
///
|
///
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub fn $method_fn() -> Route {
|
pub fn $method_fn() -> Route {
|
||||||
method(Method::$method_const)
|
method(Method::$method_const)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue