mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-10 12:54:20 +02:00
Compare commits
48 Commits
web-v2.0.0
...
files-v0.2
Author | SHA1 | Date | |
---|---|---|---|
d92d53a4f5 | |||
55d79cc1b2 | |||
a8117183bb | |||
60dcfd1aff | |||
7870165da2 | |||
6560a2285f | |||
12eccf40e1 | |||
7a9c0f632d | |||
7baa35a897 | |||
ea0d748a5e | |||
bc4f98321a | |||
2ddbe2b15c | |||
87378a7410 | |||
ad0d809af6 | |||
7b00c16d44 | |||
155a6db4cd | |||
228e886986 | |||
4aa4b5f928 | |||
54ff97470e | |||
f02ad2913f | |||
96b0dfeac3 | |||
3a5b62b550 | |||
412e54ce10 | |||
bca41f8d40 | |||
7c974ee668 | |||
abb462ef85 | |||
e66312b664 | |||
39f4b2b39e | |||
f6ff056b8a | |||
51ab4fb73d | |||
f5fd6bc49f | |||
2803fcbe22 | |||
67793c5d92 | |||
bcb5086c91 | |||
7bd2270290 | |||
a4ad5e6b69 | |||
6db909a3e7 | |||
642ae161c0 | |||
7b3c99b933 | |||
f86ce0390e | |||
7882f545e5 | |||
1c75e6876b | |||
6a0cd2dced | |||
c7f3915779 | |||
f45db1f909 | |||
3751a4018e | |||
0cb1b0642f | |||
48476362a3 |
@ -1,41 +0,0 @@
|
|||||||
environment:
|
|
||||||
global:
|
|
||||||
PROJECT_NAME: actix-web
|
|
||||||
matrix:
|
|
||||||
# Stable channel
|
|
||||||
- TARGET: i686-pc-windows-msvc
|
|
||||||
CHANNEL: stable
|
|
||||||
- TARGET: x86_64-pc-windows-gnu
|
|
||||||
CHANNEL: stable
|
|
||||||
- TARGET: x86_64-pc-windows-msvc
|
|
||||||
CHANNEL: stable
|
|
||||||
# Nightly channel
|
|
||||||
- TARGET: i686-pc-windows-msvc
|
|
||||||
CHANNEL: nightly
|
|
||||||
- TARGET: x86_64-pc-windows-gnu
|
|
||||||
CHANNEL: nightly
|
|
||||||
- TARGET: x86_64-pc-windows-msvc
|
|
||||||
CHANNEL: nightly
|
|
||||||
|
|
||||||
# Install Rust and Cargo
|
|
||||||
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
|
|
||||||
install:
|
|
||||||
- ps: >-
|
|
||||||
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
|
|
||||||
$Env:PATH += ';C:\msys64\mingw64\bin'
|
|
||||||
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
|
|
||||||
$Env:PATH += ';C:\MinGW\bin'
|
|
||||||
}
|
|
||||||
- curl -sSf -o rustup-init.exe https://win.rustup.rs
|
|
||||||
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
|
|
||||||
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
|
||||||
- rustc -Vv
|
|
||||||
- cargo -V
|
|
||||||
|
|
||||||
# 'cargo test' takes care of building for us, so disable Appveyor's build stage.
|
|
||||||
build: false
|
|
||||||
|
|
||||||
# Equivalent to Travis' `script` phase
|
|
||||||
test_script:
|
|
||||||
- cargo clean
|
|
||||||
- cargo test --no-default-features --features="flate2-rust"
|
|
37
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
37
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
name: bug report
|
||||||
|
about: create a bug report
|
||||||
|
---
|
||||||
|
|
||||||
|
Your issue may already be reported!
|
||||||
|
Please search on the [Actix Web issue tracker](https://github.com/actix/actix-web/issues) before creating one.
|
||||||
|
|
||||||
|
## Expected Behavior
|
||||||
|
<!--- If you're describing a bug, tell us what should happen -->
|
||||||
|
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||||
|
|
||||||
|
## Current Behavior
|
||||||
|
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||||
|
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||||
|
|
||||||
|
## Possible Solution
|
||||||
|
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||||
|
<!--- or ideas how to implement the addition or change -->
|
||||||
|
|
||||||
|
## Steps to Reproduce (for bugs)
|
||||||
|
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
||||||
|
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
4.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||||
|
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||||
|
|
||||||
|
## Your Environment
|
||||||
|
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||||
|
|
||||||
|
* Rust Version (I.e, output of `rustc -V`):
|
||||||
|
* Actix Web Version:
|
53
.github/workflows/linux.yml
vendored
Normal file
53
.github/workflows/linux.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: CI (Linux)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- 1.39.0 # MSRV
|
||||||
|
- stable
|
||||||
|
- nightly
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: check build
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --all --bins --examples --tests
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
timeout-minutes: 40
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --all --all-features --no-fail-fast -- --nocapture
|
||||||
|
|
||||||
|
- name: tests (actix-http)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
timeout-minutes: 40
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --package=actix-http --no-default-features --features=rustls -- --nocapture
|
||||||
|
|
||||||
|
- name: tests (awc)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
timeout-minutes: 40
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --package=awc --no-default-features --features=rustls -- --nocapture
|
39
.github/workflows/macos.yml
vendored
Normal file
39
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: CI (macOS)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
- nightly
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-apple-darwin
|
||||||
|
runs-on: macOS-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-apple-darwin
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: check build
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --all --bins --examples --tests
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --all --all-features --no-fail-fast -- --nocapture
|
||||||
|
--skip=test_h2_content_length
|
||||||
|
--skip=test_reading_deflate_encoding_large_random_rustls
|
58
.github/workflows/windows.yml
vendored
Normal file
58
.github/workflows/windows.yml
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
name: CI (Windows)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
env:
|
||||||
|
VCPKGRS_DYNAMIC: 1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
- nightly
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-pc-windows-msvc
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-pc-windows-msvc
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install OpenSSL
|
||||||
|
run: |
|
||||||
|
vcpkg integrate install
|
||||||
|
vcpkg install openssl:x64-windows
|
||||||
|
Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll
|
||||||
|
Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll
|
||||||
|
Get-ChildItem C:\vcpkg\installed\x64-windows\bin
|
||||||
|
Get-ChildItem C:\vcpkg\installed\x64-windows\lib
|
||||||
|
- name: check build
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --all --bins --examples --tests
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --all --all-features --no-fail-fast -- --nocapture
|
||||||
|
--skip=test_h2_content_length
|
||||||
|
--skip=test_reading_deflate_encoding_large_random_rustls
|
||||||
|
--skip=test_params
|
||||||
|
--skip=test_simple
|
||||||
|
--skip=test_expect_continue
|
||||||
|
--skip=test_http10_keepalive
|
||||||
|
--skip=test_slow_request
|
||||||
|
--skip=test_connection_force_close
|
||||||
|
--skip=test_connection_server_close
|
||||||
|
--skip=test_connection_wait_queue_force_close
|
61
.travis.yml
61
.travis.yml
@ -1,61 +0,0 @@
|
|||||||
language: rust
|
|
||||||
sudo: required
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
cache:
|
|
||||||
# cargo: true
|
|
||||||
apt: true
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- rust: stable
|
|
||||||
- rust: beta
|
|
||||||
- rust: nightly-2019-11-20
|
|
||||||
allow_failures:
|
|
||||||
- rust: nightly-2019-11-20
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
# - RUSTFLAGS="-C link-dead-code"
|
|
||||||
- OPENSSL_VERSION=openssl-1.0.2
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- sudo add-apt-repository -y ppa:0k53d-karl-f830m/openssl
|
|
||||||
- sudo apt-get update -qq
|
|
||||||
- sudo apt-get install -y openssl libssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev
|
|
||||||
|
|
||||||
before_cache: |
|
|
||||||
if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-11-20" ]]; then
|
|
||||||
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install --version 0.6.11 cargo-tarpaulin
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add clippy
|
|
||||||
before_script:
|
|
||||||
- export PATH=$PATH:~/.cargo/bin
|
|
||||||
|
|
||||||
script:
|
|
||||||
- cargo update
|
|
||||||
- cargo check --all --no-default-features
|
|
||||||
- |
|
|
||||||
if [[ "$TRAVIS_RUST_VERSION" == "stable" || "$TRAVIS_RUST_VERSION" == "beta" ]]; then
|
|
||||||
cargo test --all-features --all -- --nocapture
|
|
||||||
cd actix-http; cargo test --no-default-features --features="rustls" -- --nocapture; cd ..
|
|
||||||
cd awc; cargo test --no-default-features --features="rustls" -- --nocapture; cd ..
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload docs
|
|
||||||
after_success:
|
|
||||||
- |
|
|
||||||
if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_PULL_REQUEST" = "false" && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_RUST_VERSION" == "stable" ]]; then
|
|
||||||
cargo doc --no-deps --all-features &&
|
|
||||||
echo "<meta http-equiv=refresh content=0;url=os_balloon/index.html>" > target/doc/index.html &&
|
|
||||||
git clone https://github.com/davisp/ghp-import.git &&
|
|
||||||
./ghp-import/ghp_import.py -n -p -f -m "Documentation upload" -r https://"$GH_TOKEN"@github.com/"$TRAVIS_REPO_SLUG.git" target/doc &&
|
|
||||||
echo "Uploaded documentation"
|
|
||||||
fi
|
|
||||||
- |
|
|
||||||
if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-11-20" ]]; then
|
|
||||||
taskset -c 0 cargo tarpaulin --out Xml --all --all-features
|
|
||||||
bash <(curl -s https://codecov.io/bash)
|
|
||||||
echo "Uploaded code coverage"
|
|
||||||
fi
|
|
16
CHANGES.md
16
CHANGES.md
@ -1,5 +1,21 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [2.0.NEXT] - 2020-01-xx
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Use `sha-1` crate instead of unmaintained `sha1` crate
|
||||||
|
|
||||||
|
## [2.0.0] - 2019-12-25
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Rename `HttpServer::start()` to `HttpServer::run()`
|
||||||
|
|
||||||
|
* Allow to gracefully stop test server via `TestServer::stop()`
|
||||||
|
|
||||||
|
* Allow to specify multi-patterns for resources
|
||||||
|
|
||||||
## [2.0.0-rc] - 2019-12-20
|
## [2.0.0-rc] - 2019-12-20
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
14
Cargo.toml
14
Cargo.toml
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-web"
|
name = "actix-web"
|
||||||
version = "2.0.0-rc"
|
version = "2.0.0"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
|
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -60,18 +60,18 @@ rustls = ["actix-tls/rustls", "awc/rustls", "rust-tls"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.2"
|
||||||
actix-utils = "1.0.3"
|
actix-utils = "1.0.6"
|
||||||
actix-router = "0.2.0"
|
actix-router = "0.2.4"
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
actix-server = "1.0.0"
|
actix-server = "1.0.0"
|
||||||
actix-testing = "1.0.0"
|
actix-testing = "1.0.0"
|
||||||
actix-macros = "0.1.0"
|
actix-macros = "0.1.0"
|
||||||
actix-threadpool = "0.3.0"
|
actix-threadpool = "0.3.1"
|
||||||
actix-tls = "1.0.0"
|
actix-tls = "1.0.0"
|
||||||
|
|
||||||
actix-web-codegen = "0.2.0"
|
actix-web-codegen = "0.2.0"
|
||||||
actix-http = "1.0.0"
|
actix-http = "1.0.1"
|
||||||
awc = { version = "1.0.1", default-features = false }
|
awc = { version = "1.0.1", default-features = false }
|
||||||
|
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
@ -93,7 +93,7 @@ open-ssl = { version="0.10", package = "openssl", optional = true }
|
|||||||
rust-tls = { version = "0.16.0", package = "rustls", optional = true }
|
rust-tls = { version = "0.16.0", package = "rustls", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix = "0.9.0-alpha.2"
|
actix = "0.9.0"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
|
38
MIGRATION.md
38
MIGRATION.md
@ -1,16 +1,50 @@
|
|||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
|
* `HttpServer::start()` renamed to `HttpServer::run()`. It also possible to
|
||||||
|
`.await` on `run` method result, in that case it awaits server exit.
|
||||||
|
|
||||||
* `App::register_data()` renamed to `App::app_data()` and accepts any type `T: 'static`.
|
* `App::register_data()` renamed to `App::app_data()` and accepts any type `T: 'static`.
|
||||||
Stored data is available via `HttpRequest::app_data()` method at runtime.
|
Stored data is available via `HttpRequest::app_data()` method at runtime.
|
||||||
|
|
||||||
* Extractor configuration must be registered with `App::app_data()` instead of `App::data()`
|
* Extractor configuration must be registered with `App::app_data()` instead of `App::data()`
|
||||||
|
|
||||||
* Sync handlers has been removed. `.to_async()` method has been renamed to `.to()`
|
* Sync handlers has been removed. `.to_async()` method has been renamed to `.to()`
|
||||||
|
|
||||||
replace `fn` with `async fn` to convert sync handler to async
|
replace `fn` with `async fn` to convert sync handler to async
|
||||||
|
|
||||||
* `TestServer::new()` renamed to `TestServer::start()`
|
* `actix_http_test::TestServer` moved to `actix_web::test` module. To start
|
||||||
|
test server use `test::start()` or `test_start_with_config()` methods
|
||||||
|
|
||||||
|
* `ResponseError` trait has been reafctored. `ResponseError::error_response()` renders
|
||||||
|
http response.
|
||||||
|
|
||||||
|
* Feature `rust-tls` renamed to `rustls`
|
||||||
|
|
||||||
|
instead of
|
||||||
|
|
||||||
|
```rust
|
||||||
|
actix-web = { version = "2.0.0", features = ["rust-tls"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
use
|
||||||
|
|
||||||
|
```rust
|
||||||
|
actix-web = { version = "2.0.0", features = ["rustls"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
* Feature `ssl` renamed to `openssl`
|
||||||
|
|
||||||
|
instead of
|
||||||
|
|
||||||
|
```rust
|
||||||
|
actix-web = { version = "2.0.0", features = ["ssl"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
use
|
||||||
|
|
||||||
|
```rust
|
||||||
|
actix-web = { version = "2.0.0", features = ["openssl"] }
|
||||||
|
```
|
||||||
|
* `Cors` builder now requires that you call `.finish()` to construct the middleware
|
||||||
|
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
|
17
README.md
17
README.md
@ -41,6 +41,16 @@ Actix web is a simple, pragmatic and extremely fast web framework for Rust.
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[dependencies]
|
||||||
|
actix-web = "2"
|
||||||
|
actix-rt = "1"
|
||||||
|
```
|
||||||
|
|
||||||
|
Code:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use actix_web::{get, web, App, HttpServer, Responder};
|
use actix_web::{get, web, App, HttpServer, Responder};
|
||||||
|
|
||||||
@ -53,7 +63,7 @@ async fn index(info: web::Path<(u32, String)>) -> impl Responder {
|
|||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| App::new().service(index))
|
HttpServer::new(|| App::new().service(index))
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("127.0.0.1:8080")?
|
||||||
.start()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -65,10 +75,11 @@ async fn main() -> std::io::Result<()> {
|
|||||||
* [Multipart streams](https://github.com/actix/examples/tree/master/multipart/)
|
* [Multipart streams](https://github.com/actix/examples/tree/master/multipart/)
|
||||||
* [Simple websocket](https://github.com/actix/examples/tree/master/websocket/)
|
* [Simple websocket](https://github.com/actix/examples/tree/master/websocket/)
|
||||||
* [Tera](https://github.com/actix/examples/tree/master/template_tera/) /
|
* [Tera](https://github.com/actix/examples/tree/master/template_tera/) /
|
||||||
[Askama](https://github.com/actix/examples/tree/master/template_askama/) templates
|
* [Askama](https://github.com/actix/examples/tree/master/template_askama/) templates
|
||||||
* [Diesel integration](https://github.com/actix/examples/tree/master/diesel/)
|
* [Diesel integration](https://github.com/actix/examples/tree/master/diesel/)
|
||||||
* [r2d2](https://github.com/actix/examples/tree/master/r2d2/)
|
* [r2d2](https://github.com/actix/examples/tree/master/r2d2/)
|
||||||
* [SSL / HTTP/2.0](https://github.com/actix/examples/tree/master/tls/)
|
* [OpenSSL](https://github.com/actix/examples/tree/master/openssl/)
|
||||||
|
* [Rustls](https://github.com/actix/examples/tree/master/rustls/)
|
||||||
* [Tcp/Websocket chat](https://github.com/actix/examples/tree/master/websocket-chat/)
|
* [Tcp/Websocket chat](https://github.com/actix/examples/tree/master/websocket-chat/)
|
||||||
* [Json](https://github.com/actix/examples/tree/master/json/)
|
* [Json](https://github.com/actix/examples/tree/master/json/)
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [0.2.0-alpha.3] - 2019-12-07
|
## [0.2.0-alpha.3] - 2019-12-07
|
||||||
|
|
||||||
* Migrate to actix-web 2.0.0
|
* Migrate to actix-web 2.0.0
|
||||||
|
@ -18,7 +18,7 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "2.0.0-rc"
|
actix-web = "2.0.0-rc"
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ where
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.boxed_local(),
|
.boxed_local(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [0.2.0] - 2019-12-xx
|
## [0.2.2] - 2020-05-26
|
||||||
|
|
||||||
|
* Minimize `futures` dependency
|
||||||
|
* Support sending Content-Length when Content-Range is specified [#1496]
|
||||||
|
* Update `actix-web` to 2.0.0
|
||||||
|
|
||||||
|
[#1496]: https://github.com/actix/actix-web/issues/1496
|
||||||
|
|
||||||
|
## [0.2.1] - 2019-12-22
|
||||||
|
|
||||||
|
* Use the same format for file URLs regardless of platforms
|
||||||
|
|
||||||
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
* Fix BodyEncoding trait import #1220
|
* Fix BodyEncoding trait import #1220
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-files"
|
name = "actix-files"
|
||||||
version = "0.2.0"
|
version = "0.2.2"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Static files support for actix web."
|
description = "Static files support for actix web."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -18,12 +18,13 @@ name = "actix_files"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "2.0.0-rc", default-features = false }
|
actix-web = { version = "2.0.0", default-features = false }
|
||||||
actix-http = "1.0.1"
|
actix-http = "1.0.1"
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
futures = "0.3.1"
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
@ -33,4 +34,4 @@ v_htmlescape = "0.4"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
actix-web = { version = "2.0.0-rc", features=["openssl"] }
|
actix-web = { version = "2.0.0", features = ["openssl"] }
|
||||||
|
@ -5,6 +5,7 @@ use derive_more::Display;
|
|||||||
#[derive(Display, Debug, PartialEq)]
|
#[derive(Display, Debug, PartialEq)]
|
||||||
pub enum FilesError {
|
pub enum FilesError {
|
||||||
/// Path is not a directory
|
/// Path is not a directory
|
||||||
|
#[allow(dead_code)]
|
||||||
#[display(fmt = "Path is not a directory. Unable to serve static files")]
|
#[display(fmt = "Path is not a directory. Unable to serve static files")]
|
||||||
IsNotDirectory,
|
IsNotDirectory,
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ use actix_web::http::header::{self, DispositionType};
|
|||||||
use actix_web::http::Method;
|
use actix_web::http::Method;
|
||||||
use actix_web::{web, FromRequest, HttpRequest, HttpResponse};
|
use actix_web::{web, FromRequest, HttpRequest, HttpResponse};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{ok, ready, Either, FutureExt, LocalBoxFuture, Ready};
|
use futures_core::Stream;
|
||||||
use futures::Stream;
|
use futures_util::future::{ok, ready, Either, FutureExt, LocalBoxFuture, Ready};
|
||||||
use mime;
|
use mime;
|
||||||
use mime_guess::from_ext;
|
use mime_guess::from_ext;
|
||||||
use percent_encoding::{utf8_percent_encode, CONTROLS};
|
use percent_encoding::{utf8_percent_encode, CONTROLS};
|
||||||
@ -155,7 +155,7 @@ impl Directory {
|
|||||||
// show file url as relative to static path
|
// show file url as relative to static path
|
||||||
macro_rules! encode_file_url {
|
macro_rules! encode_file_url {
|
||||||
($path:ident) => {
|
($path:ident) => {
|
||||||
utf8_percent_encode(&$path.to_string_lossy(), CONTROLS)
|
utf8_percent_encode(&$path, CONTROLS)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,10 @@ fn directory_listing(
|
|||||||
if dir.is_visible(&entry) {
|
if dir.is_visible(&entry) {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
let p = match entry.path().strip_prefix(&dir.path) {
|
let p = match entry.path().strip_prefix(&dir.path) {
|
||||||
Ok(p) => base.join(p),
|
Ok(p) if cfg!(windows) => {
|
||||||
|
base.join(p).to_string_lossy().replace("\\", "/")
|
||||||
|
}
|
||||||
|
Ok(p) => base.join(p).to_string_lossy().into_owned(),
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -272,7 +275,7 @@ impl Files {
|
|||||||
///
|
///
|
||||||
/// `File` uses `ThreadPool` for blocking filesystem operations.
|
/// `File` uses `ThreadPool` for blocking filesystem operations.
|
||||||
/// By default pool with 5x threads of available cpus is used.
|
/// By default pool with 5x threads of available cpus is used.
|
||||||
/// Pool size can be changed by setting ACTIX_CPU_POOL environment variable.
|
/// Pool size can be changed by setting ACTIX_THREADPOOL environment variable.
|
||||||
pub fn new<T: Into<PathBuf>>(path: &str, dir: T) -> Files {
|
pub fn new<T: Into<PathBuf>>(path: &str, dir: T) -> Files {
|
||||||
let orig_dir = dir.into();
|
let orig_dir = dir.into();
|
||||||
let dir = match orig_dir.canonicalize() {
|
let dir = match orig_dir.canonicalize() {
|
||||||
@ -518,7 +521,7 @@ impl Service for FilesService {
|
|||||||
Err(e) => return Either::Left(ok(req.error_response(e))),
|
Err(e) => return Either::Left(ok(req.error_response(e))),
|
||||||
};
|
};
|
||||||
|
|
||||||
// full filepath
|
// full file path
|
||||||
let path = match self.directory.join(&real_path.0).canonicalize() {
|
let path = match self.directory.join(&real_path.0).canonicalize() {
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
Err(e) => return self.handle_err(e, req),
|
Err(e) => return self.handle_err(e, req),
|
||||||
@ -949,135 +952,92 @@ mod tests {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_named_file_content_range_headers() {
|
async fn test_named_file_content_range_headers() {
|
||||||
let mut srv = test::init_service(
|
let srv = test::start(|| {
|
||||||
App::new().service(Files::new("/test", ".").index_file("tests/test.binary")),
|
App::new().service(Files::new("/", "."))
|
||||||
)
|
});
|
||||||
.await;
|
|
||||||
|
|
||||||
// Valid range header
|
// Valid range header
|
||||||
let request = TestRequest::get()
|
let response = srv
|
||||||
.uri("/t%65st/tests/test.binary")
|
.get("/tests/test.binary")
|
||||||
.header(header::RANGE, "bytes=10-20")
|
.header(header::RANGE, "bytes=10-20")
|
||||||
.to_request();
|
.send()
|
||||||
|
.await
|
||||||
let response = test::call_service(&mut srv, request).await;
|
|
||||||
let contentrange = response
|
|
||||||
.headers()
|
|
||||||
.get(header::CONTENT_RANGE)
|
|
||||||
.unwrap()
|
|
||||||
.to_str()
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let content_range = response.headers().get(header::CONTENT_RANGE).unwrap();
|
||||||
assert_eq!(contentrange, "bytes 10-20/100");
|
assert_eq!(content_range.to_str().unwrap(), "bytes 10-20/100");
|
||||||
|
|
||||||
// Invalid range header
|
// Invalid range header
|
||||||
let request = TestRequest::get()
|
let response = srv
|
||||||
.uri("/t%65st/tests/test.binary")
|
.get("/tests/test.binary")
|
||||||
.header(header::RANGE, "bytes=10-5")
|
.header(header::RANGE, "bytes=10-5")
|
||||||
.to_request();
|
.send()
|
||||||
let response = test::call_service(&mut srv, request).await;
|
.await
|
||||||
|
|
||||||
let contentrange = response
|
|
||||||
.headers()
|
|
||||||
.get(header::CONTENT_RANGE)
|
|
||||||
.unwrap()
|
|
||||||
.to_str()
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let content_range = response.headers().get(header::CONTENT_RANGE).unwrap();
|
||||||
assert_eq!(contentrange, "bytes */100");
|
assert_eq!(content_range.to_str().unwrap(), "bytes */100");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_named_file_content_length_headers() {
|
async fn test_named_file_content_length_headers() {
|
||||||
// use actix_web::body::{MessageBody, ResponseBody};
|
let srv = test::start(|| {
|
||||||
|
App::new().service(Files::new("/", "."))
|
||||||
let mut srv = test::init_service(
|
});
|
||||||
App::new().service(Files::new("test", ".").index_file("tests/test.binary")),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Valid range header
|
// Valid range header
|
||||||
let request = TestRequest::get()
|
let response = srv
|
||||||
.uri("/t%65st/tests/test.binary")
|
.get("/tests/test.binary")
|
||||||
.header(header::RANGE, "bytes=10-20")
|
.header(header::RANGE, "bytes=10-20")
|
||||||
.to_request();
|
.send()
|
||||||
let _response = test::call_service(&mut srv, request).await;
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let content_length = response.headers().get(header::CONTENT_LENGTH).unwrap();
|
||||||
|
assert_eq!(content_length.to_str().unwrap(), "11");
|
||||||
|
|
||||||
// let contentlength = response
|
// Valid range header, starting from 0
|
||||||
// .headers()
|
let response = srv
|
||||||
// .get(header::CONTENT_LENGTH)
|
.get("/tests/test.binary")
|
||||||
// .unwrap()
|
.header(header::RANGE, "bytes=0-20")
|
||||||
// .to_str()
|
.send()
|
||||||
// .unwrap();
|
.await
|
||||||
// assert_eq!(contentlength, "11");
|
.unwrap();
|
||||||
|
let content_length = response.headers().get(header::CONTENT_LENGTH).unwrap();
|
||||||
// Invalid range header
|
assert_eq!(content_length.to_str().unwrap(), "21");
|
||||||
let request = TestRequest::get()
|
|
||||||
.uri("/t%65st/tests/test.binary")
|
|
||||||
.header(header::RANGE, "bytes=10-8")
|
|
||||||
.to_request();
|
|
||||||
let response = test::call_service(&mut srv, request).await;
|
|
||||||
assert_eq!(response.status(), StatusCode::RANGE_NOT_SATISFIABLE);
|
|
||||||
|
|
||||||
// Without range header
|
// Without range header
|
||||||
let request = TestRequest::get()
|
let mut response = srv.get("/tests/test.binary").send().await.unwrap();
|
||||||
.uri("/t%65st/tests/test.binary")
|
let content_length = response.headers().get(header::CONTENT_LENGTH).unwrap();
|
||||||
// .no_default_headers()
|
assert_eq!(content_length.to_str().unwrap(), "100");
|
||||||
.to_request();
|
|
||||||
let _response = test::call_service(&mut srv, request).await;
|
|
||||||
|
|
||||||
// let contentlength = response
|
// Should be no transfer-encoding
|
||||||
// .headers()
|
let transfer_encoding = response.headers().get(header::TRANSFER_ENCODING);
|
||||||
// .get(header::CONTENT_LENGTH)
|
assert!(transfer_encoding.is_none());
|
||||||
// .unwrap()
|
|
||||||
// .to_str()
|
|
||||||
// .unwrap();
|
|
||||||
// assert_eq!(contentlength, "100");
|
|
||||||
|
|
||||||
// chunked
|
// Check file contents
|
||||||
let request = TestRequest::get()
|
let bytes = response.body().await.unwrap();
|
||||||
.uri("/t%65st/tests/test.binary")
|
|
||||||
.to_request();
|
|
||||||
let response = test::call_service(&mut srv, request).await;
|
|
||||||
|
|
||||||
// with enabled compression
|
|
||||||
// {
|
|
||||||
// let te = response
|
|
||||||
// .headers()
|
|
||||||
// .get(header::TRANSFER_ENCODING)
|
|
||||||
// .unwrap()
|
|
||||||
// .to_str()
|
|
||||||
// .unwrap();
|
|
||||||
// assert_eq!(te, "chunked");
|
|
||||||
// }
|
|
||||||
|
|
||||||
let bytes = test::read_body(response).await;
|
|
||||||
let data = Bytes::from(fs::read("tests/test.binary").unwrap());
|
let data = Bytes::from(fs::read("tests/test.binary").unwrap());
|
||||||
assert_eq!(bytes, data);
|
assert_eq!(bytes, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_head_content_length_headers() {
|
async fn test_head_content_length_headers() {
|
||||||
let mut srv = test::init_service(
|
let srv = test::start(|| {
|
||||||
App::new().service(Files::new("test", ".").index_file("tests/test.binary")),
|
App::new().service(Files::new("/", "."))
|
||||||
)
|
});
|
||||||
.await;
|
|
||||||
|
|
||||||
// Valid range header
|
let response = srv
|
||||||
let request = TestRequest::default()
|
.head("/tests/test.binary")
|
||||||
.method(Method::HEAD)
|
.send()
|
||||||
.uri("/t%65st/tests/test.binary")
|
.await
|
||||||
.to_request();
|
.unwrap();
|
||||||
let _response = test::call_service(&mut srv, request).await;
|
|
||||||
|
|
||||||
// TODO: fix check
|
let content_length = response
|
||||||
// let contentlength = response
|
.headers()
|
||||||
// .headers()
|
.get(header::CONTENT_LENGTH)
|
||||||
// .get(header::CONTENT_LENGTH)
|
.unwrap()
|
||||||
// .unwrap()
|
.to_str()
|
||||||
// .to_str()
|
.unwrap();
|
||||||
// .unwrap();
|
|
||||||
// assert_eq!(contentlength, "100");
|
assert_eq!(content_length, "100");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
@ -18,7 +18,7 @@ use actix_web::http::header::{
|
|||||||
};
|
};
|
||||||
use actix_web::http::{ContentEncoding, StatusCode};
|
use actix_web::http::{ContentEncoding, StatusCode};
|
||||||
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse, Responder};
|
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse, Responder};
|
||||||
use futures::future::{ready, Ready};
|
use futures_util::future::{ready, Ready};
|
||||||
|
|
||||||
use crate::range::HttpRange;
|
use crate::range::HttpRange;
|
||||||
use crate::ChunkedReadFile;
|
use crate::ChunkedReadFile;
|
||||||
@ -388,11 +388,12 @@ impl NamedFile {
|
|||||||
fut: None,
|
fut: None,
|
||||||
counter: 0,
|
counter: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if offset != 0 || length != self.md.len() {
|
if offset != 0 || length != self.md.len() {
|
||||||
Ok(resp.status(StatusCode::PARTIAL_CONTENT).streaming(reader))
|
resp.status(StatusCode::PARTIAL_CONTENT);
|
||||||
} else {
|
|
||||||
Ok(resp.body(SizedStream::new(length, reader)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(resp.body(SizedStream::new(length, reader)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-framed"
|
name = "actix-framed"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix framed app server"
|
description = "Actix framed app server"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -13,7 +13,6 @@ categories = ["network-programming", "asynchronous",
|
|||||||
"web-programming::websocket"]
|
"web-programming::websocket"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
workspace =".."
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "actix_framed"
|
name = "actix_framed"
|
||||||
@ -21,10 +20,10 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
actix-router = "0.2.0"
|
actix-router = "0.2.1"
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
actix-http = "1.0.0"
|
actix-http = "1.0.1"
|
||||||
|
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# Framed app for actix web [](https://travis-ci.org/actix/actix-web) [](https://codecov.io/gh/actix/actix-web) [](https://crates.io/crates/actix-framed) [](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
# Framed app for actix web [](https://travis-ci.org/actix/actix-web) [](https://codecov.io/gh/actix/actix-web) [](https://crates.io/crates/actix-framed) [](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
**Notice**: `actix-framed` is deprecated since we don't use it anymore.
|
||||||
|
|
||||||
## Documentation & community resources
|
## Documentation & community resources
|
||||||
|
|
||||||
* [API Documentation](https://docs.rs/actix-framed/)
|
* [API Documentation](https://docs.rs/actix-framed/)
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.3.1] - 2020-05-25
|
||||||
|
|
||||||
|
* Deprecate this crate
|
||||||
|
|
||||||
|
## [0.3.0] - 2019-12-25
|
||||||
|
|
||||||
|
* Migrate to actix-http 1.0
|
||||||
|
|
||||||
## [0.2.1] - 2019-07-20
|
## [0.2.1] - 2019-07-20
|
||||||
|
|
||||||
* Remove unneeded actix-utils dependency
|
* Remove unneeded actix-utils dependency
|
||||||
|
@ -66,7 +66,7 @@ where
|
|||||||
service
|
service
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,6 @@ where
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ failure = ["fail-ure"]
|
|||||||
secure-cookies = ["ring"]
|
secure-cookies = ["ring"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
actix-connect = "1.0.1"
|
actix-connect = "1.0.1"
|
||||||
actix-utils = "1.0.3"
|
actix-utils = "1.0.3"
|
||||||
@ -74,7 +74,7 @@ rand = "0.7"
|
|||||||
regex = "1.3"
|
regex = "1.3"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sha1 = "0.6"
|
sha-1 = "0.8"
|
||||||
slab = "0.4"
|
slab = "0.4"
|
||||||
serde_urlencoded = "0.6.1"
|
serde_urlencoded = "0.6.1"
|
||||||
time = "0.1.42"
|
time = "0.1.42"
|
||||||
|
@ -7,7 +7,8 @@ use futures::StreamExt;
|
|||||||
use http::header::HeaderValue;
|
use http::header::HeaderValue;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> io::Result<()> {
|
||||||
env::set_var("RUST_LOG", "echo=info");
|
env::set_var("RUST_LOG", "echo=info");
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
@ -37,4 +38,5 @@ fn main() -> io::Result<()> {
|
|||||||
.tcp()
|
.tcp()
|
||||||
})?
|
})?
|
||||||
.run()
|
.run()
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ async fn handle_request(mut req: Request) -> Result<Response, Error> {
|
|||||||
.body(body))
|
.body(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> io::Result<()> {
|
||||||
env::set_var("RUST_LOG", "echo=info");
|
env::set_var("RUST_LOG", "echo=info");
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
@ -28,4 +29,5 @@ fn main() -> io::Result<()> {
|
|||||||
HttpService::build().finish(handle_request).tcp()
|
HttpService::build().finish(handle_request).tcp()
|
||||||
})?
|
})?
|
||||||
.run()
|
.run()
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ use futures::future;
|
|||||||
use http::header::HeaderValue;
|
use http::header::HeaderValue;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> io::Result<()> {
|
||||||
env::set_var("RUST_LOG", "hello_world=info");
|
env::set_var("RUST_LOG", "hello_world=info");
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
@ -24,4 +25,5 @@ fn main() -> io::Result<()> {
|
|||||||
.tcp()
|
.tcp()
|
||||||
})?
|
})?
|
||||||
.run()
|
.run()
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
@ -6,27 +6,21 @@ use actix_service::Service;
|
|||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// Service that allows to turn non-clone service to a service with `Clone` impl
|
/// Service that allows to turn non-clone service to a service with `Clone` impl
|
||||||
pub(crate) struct CloneableService<T>(Rc<UnsafeCell<T>>);
|
pub(crate) struct CloneableService<T: Service>(Rc<UnsafeCell<T>>);
|
||||||
|
|
||||||
impl<T> CloneableService<T> {
|
impl<T: Service> CloneableService<T> {
|
||||||
pub(crate) fn new(service: T) -> Self
|
pub(crate) fn new(service: T) -> Self {
|
||||||
where
|
|
||||||
T: Service,
|
|
||||||
{
|
|
||||||
Self(Rc::new(UnsafeCell::new(service)))
|
Self(Rc::new(UnsafeCell::new(service)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for CloneableService<T> {
|
impl<T: Service> Clone for CloneableService<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self(self.0.clone())
|
Self(self.0.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Service for CloneableService<T>
|
impl<T: Service> Service for CloneableService<T> {
|
||||||
where
|
|
||||||
T: Service,
|
|
||||||
{
|
|
||||||
type Request = T::Request;
|
type Request = T::Request;
|
||||||
type Response = T::Response;
|
type Response = T::Response;
|
||||||
type Error = T::Error;
|
type Error = T::Error;
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/cookie/0.11")]
|
#![doc(html_root_url = "https://docs.rs/cookie/0.11")]
|
||||||
#![deny(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
mod builder;
|
mod builder;
|
||||||
mod delta;
|
mod delta;
|
||||||
|
@ -364,7 +364,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// `Service` implementation for HTTP1 transport
|
/// `Service` implementation for HTTP1 transport
|
||||||
pub struct H1ServiceHandler<T, S, B, X, U> {
|
pub struct H1ServiceHandler<T, S: Service, B, X: Service, U: Service> {
|
||||||
srv: CloneableService<S>,
|
srv: CloneableService<S>,
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
|
@ -246,7 +246,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// `Service` implementation for http/2 transport
|
/// `Service` implementation for http/2 transport
|
||||||
pub struct H2ServiceHandler<T, S, B> {
|
pub struct H2ServiceHandler<T, S: Service, B> {
|
||||||
srv: CloneableService<S>,
|
srv: CloneableService<S>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! Basic http primitives for actix-net framework.
|
//! Basic http primitives for actix-net framework.
|
||||||
#![deny(rust_2018_idioms, warnings)]
|
#![warn(rust_2018_idioms, warnings)]
|
||||||
#![allow(
|
#![allow(
|
||||||
clippy::type_complexity,
|
clippy::type_complexity,
|
||||||
clippy::too_many_arguments,
|
clippy::too_many_arguments,
|
||||||
|
@ -443,7 +443,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// `Service` implementation for http transport
|
/// `Service` implementation for http transport
|
||||||
pub struct HttpServiceHandler<T, S, B, X, U> {
|
pub struct HttpServiceHandler<T, S: Service, B, X: Service, U: Service> {
|
||||||
srv: CloneableService<S>,
|
srv: CloneableService<S>,
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
|
@ -207,12 +207,13 @@ static WS_GUID: &str = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|||||||
|
|
||||||
// TODO: hash is always same size, we dont need String
|
// TODO: hash is always same size, we dont need String
|
||||||
pub fn hash_key(key: &[u8]) -> String {
|
pub fn hash_key(key: &[u8]) -> String {
|
||||||
|
use sha1::Digest;
|
||||||
let mut hasher = sha1::Sha1::new();
|
let mut hasher = sha1::Sha1::new();
|
||||||
|
|
||||||
hasher.update(key);
|
hasher.input(key);
|
||||||
hasher.update(WS_GUID.as_bytes());
|
hasher.input(WS_GUID.as_bytes());
|
||||||
|
|
||||||
base64::encode(&hasher.digest().bytes())
|
base64::encode(hasher.result().as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -277,6 +278,12 @@ mod test {
|
|||||||
assert_eq!(format!("{}", OpCode::Bad), "BAD");
|
assert_eq!(format!("{}", OpCode::Bad), "BAD");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hash_key() {
|
||||||
|
let hash = hash_key(b"hello actix-web");
|
||||||
|
assert_eq!(&hash, "cR1dlyUUJKp0s/Bel25u5TgvC3E=");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn closecode_from_u16() {
|
fn closecode_from_u16() {
|
||||||
assert_eq!(CloseCode::from(1000u16), CloseCode::Normal);
|
assert_eq!(CloseCode::from(1000u16), CloseCode::Normal);
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.2.1] - 2020-01-10
|
||||||
|
|
||||||
|
* Fix panic with already borrowed: BorrowMutError #1263
|
||||||
|
|
||||||
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Use actix-web 2.0
|
||||||
|
|
||||||
## [0.1.0] - 2019-06-xx
|
## [0.1.0] - 2019-06-xx
|
||||||
|
|
||||||
* Move identity middleware to separate crate
|
* Move identity middleware to separate crate
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-identity"
|
name = "actix-identity"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Identity service for actix web framework."
|
description = "Identity service for actix web framework."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -10,15 +10,14 @@ repository = "https://github.com/actix/actix-web.git"
|
|||||||
documentation = "https://docs.rs/actix-identity/"
|
documentation = "https://docs.rs/actix-identity/"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
workspace = ".."
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "actix_identity"
|
name = "actix_identity"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "2.0.0-rc", default-features = false, features = ["secure-cookies"] }
|
actix-web = { version = "2.0.0", default-features = false, features = ["secure-cookies"] }
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.2"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
@ -251,6 +251,15 @@ pub struct IdentityServiceMiddleware<S, T> {
|
|||||||
service: Rc<RefCell<S>>,
|
service: Rc<RefCell<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S, T> Clone for IdentityServiceMiddleware<S, T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
backend: self.backend.clone(),
|
||||||
|
service: self.service.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<S, T, B> Service for IdentityServiceMiddleware<S, T>
|
impl<S, T, B> Service for IdentityServiceMiddleware<S, T>
|
||||||
where
|
where
|
||||||
B: 'static,
|
B: 'static,
|
||||||
@ -279,7 +288,9 @@ where
|
|||||||
req.extensions_mut()
|
req.extensions_mut()
|
||||||
.insert(IdentityItem { id, changed: false });
|
.insert(IdentityItem { id, changed: false });
|
||||||
|
|
||||||
let mut res = srv.borrow_mut().call(req).await?;
|
// https://github.com/actix/actix-web/issues/1263
|
||||||
|
let fut = { srv.borrow_mut().call(req) };
|
||||||
|
let mut res = fut.await?;
|
||||||
let id = res.request().extensions_mut().remove::<IdentityItem>();
|
let id = res.request().extensions_mut().remove::<IdentityItem>();
|
||||||
|
|
||||||
if let Some(id) = id {
|
if let Some(id) = id {
|
||||||
@ -294,7 +305,7 @@ where
|
|||||||
Err(err) => Ok(req.error_response(err)),
|
Err(err) => Ok(req.error_response(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,9 +617,10 @@ mod tests {
|
|||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use actix_service::into_service;
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test::{self, TestRequest};
|
use actix_web::test::{self, TestRequest};
|
||||||
use actix_web::{web, App, Error, HttpResponse};
|
use actix_web::{error, web, App, Error, HttpResponse};
|
||||||
|
|
||||||
const COOKIE_KEY_MASTER: [u8; 32] = [0; 32];
|
const COOKIE_KEY_MASTER: [u8; 32] = [0; 32];
|
||||||
const COOKIE_NAME: &'static str = "actix_auth";
|
const COOKIE_NAME: &'static str = "actix_auth";
|
||||||
@ -1045,6 +1057,7 @@ mod tests {
|
|||||||
assert_logged_in(resp, Some(COOKIE_LOGIN)).await;
|
assert_logged_in(resp, Some(COOKIE_LOGIN)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/actix/actix-web/issues/1263
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_identity_cookie_updated_on_visit_deadline() {
|
async fn test_identity_cookie_updated_on_visit_deadline() {
|
||||||
let mut srv = create_identity_server(|c| {
|
let mut srv = create_identity_server(|c| {
|
||||||
@ -1069,4 +1082,47 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_logged_in(resp, Some(COOKIE_LOGIN)).await;
|
assert_logged_in(resp, Some(COOKIE_LOGIN)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_borrowed_mut_error() {
|
||||||
|
use futures::future::{lazy, ok, Ready};
|
||||||
|
|
||||||
|
struct Ident;
|
||||||
|
impl IdentityPolicy for Ident {
|
||||||
|
type Future = Ready<Result<Option<String>, Error>>;
|
||||||
|
type ResponseFuture = Ready<Result<(), Error>>;
|
||||||
|
|
||||||
|
fn from_request(&self, _: &mut ServiceRequest) -> Self::Future {
|
||||||
|
ok(Some("test".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_response<B>(
|
||||||
|
&self,
|
||||||
|
_: Option<String>,
|
||||||
|
_: bool,
|
||||||
|
_: &mut ServiceResponse<B>,
|
||||||
|
) -> Self::ResponseFuture {
|
||||||
|
ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut srv = IdentityServiceMiddleware {
|
||||||
|
backend: Rc::new(Ident),
|
||||||
|
service: Rc::new(RefCell::new(into_service(|_: ServiceRequest| {
|
||||||
|
async move {
|
||||||
|
actix_rt::time::delay_for(std::time::Duration::from_secs(100)).await;
|
||||||
|
Err::<ServiceResponse, _>(error::ErrorBadRequest("error"))
|
||||||
|
}
|
||||||
|
}))),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut srv2 = srv.clone();
|
||||||
|
let req = TestRequest::default().to_srv_request();
|
||||||
|
actix_rt::spawn(async move {
|
||||||
|
let _ = srv2.call(req).await;
|
||||||
|
});
|
||||||
|
actix_rt::time::delay_for(std::time::Duration::from_millis(50)).await;
|
||||||
|
|
||||||
|
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [2.0.0-alpha.4] - 2019-12-xx
|
## [0.2.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
|
## [0.2.0-alpha.4] - 2019-12-xx
|
||||||
|
|
||||||
* Multipart handling now handles Pending during read of boundary #1205
|
* Multipart handling now handles Pending during read of boundary #1205
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "2.0.0-rc", default-features = false }
|
actix-web = { version = "2.0.0-rc", default-features = false }
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
actix-utils = "1.0.3"
|
actix-utils = "1.0.3"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.3.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [0.3.0-alpha.4] - 2019-12-xx
|
## [0.3.0-alpha.4] - 2019-12-xx
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ cookie-session = ["actix-web/secure-cookies"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "2.0.0-rc"
|
actix-web = "2.0.0-rc"
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
|
@ -354,7 +354,7 @@ where
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
//! )
|
//! )
|
||||||
//! .service(web::resource("/").to(|| HttpResponse::Ok())))
|
//! .service(web::resource("/").to(|| HttpResponse::Ok())))
|
||||||
//! .bind("127.0.0.1:59880")?
|
//! .bind("127.0.0.1:59880")?
|
||||||
//! .start()
|
//! .run()
|
||||||
//! .await
|
//! .await
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [2.0.0] - 2019-12-20
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [2.0.0-alpha.1] - 2019-12-15
|
## [2.0.0-alpha.1] - 2019-12-15
|
||||||
|
|
||||||
* Migrate to actix-web 2.0.0
|
* Migrate to actix-web 2.0.0
|
||||||
|
@ -35,7 +35,7 @@ compress = ["actix-http/compress"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
actix-http = "1.0.0"
|
actix-http = "1.0.0"
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#![deny(rust_2018_idioms, warnings)]
|
#![warn(rust_2018_idioms, warnings)]
|
||||||
#![allow(
|
#![allow(
|
||||||
clippy::type_complexity,
|
clippy::type_complexity,
|
||||||
clippy::borrow_interior_mutable_const,
|
clippy::borrow_interior_mutable_const,
|
||||||
|
@ -14,7 +14,7 @@ use rand::Rng;
|
|||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::{map_config, pipeline_factory, IntoServiceFactory};
|
use actix_service::{map_config, pipeline_factory};
|
||||||
use actix_web::dev::{AppConfig, BodyEncoding};
|
use actix_web::dev::{AppConfig, BodyEncoding};
|
||||||
use actix_web::http::Cookie;
|
use actix_web::http::Cookie;
|
||||||
use actix_web::middleware::Compress;
|
use actix_web::middleware::Compress;
|
||||||
@ -172,8 +172,7 @@ async fn test_connection_reuse() {
|
|||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(map_config(
|
HttpService::new(map_config(
|
||||||
App::new()
|
App::new()
|
||||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
|
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
|
||||||
.into_factory(),
|
|
||||||
|_| AppConfig::default(),
|
|_| AppConfig::default(),
|
||||||
))
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
@ -210,8 +209,7 @@ async fn test_connection_force_close() {
|
|||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(map_config(
|
HttpService::new(map_config(
|
||||||
App::new()
|
App::new()
|
||||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
|
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
|
||||||
.into_factory(),
|
|
||||||
|_| AppConfig::default(),
|
|_| AppConfig::default(),
|
||||||
))
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
@ -239,25 +237,23 @@ async fn test_connection_server_close() {
|
|||||||
let num = Arc::new(AtomicUsize::new(0));
|
let num = Arc::new(AtomicUsize::new(0));
|
||||||
let num2 = num.clone();
|
let num2 = num.clone();
|
||||||
|
|
||||||
let srv =
|
let srv = test_server(move || {
|
||||||
test_server(move || {
|
let num2 = num2.clone();
|
||||||
let num2 = num2.clone();
|
pipeline_factory(move |io| {
|
||||||
pipeline_factory(move |io| {
|
num2.fetch_add(1, Ordering::Relaxed);
|
||||||
num2.fetch_add(1, Ordering::Relaxed);
|
ok(io)
|
||||||
ok(io)
|
})
|
||||||
})
|
.and_then(
|
||||||
.and_then(
|
HttpService::new(map_config(
|
||||||
HttpService::new(map_config(
|
App::new().service(
|
||||||
App::new()
|
web::resource("/")
|
||||||
.service(web::resource("/").route(web::to(|| {
|
.route(web::to(|| HttpResponse::Ok().force_close().finish())),
|
||||||
HttpResponse::Ok().force_close().finish()
|
),
|
||||||
})))
|
|_| AppConfig::default(),
|
||||||
.into_factory(),
|
))
|
||||||
|_| AppConfig::default(),
|
.tcp(),
|
||||||
))
|
)
|
||||||
.tcp(),
|
});
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
let client = awc::Client::default();
|
let client = awc::Client::default();
|
||||||
|
|
||||||
@ -288,12 +284,9 @@ async fn test_connection_wait_queue() {
|
|||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(map_config(
|
HttpService::new(map_config(
|
||||||
App::new()
|
App::new().service(
|
||||||
.service(
|
web::resource("/").route(web::to(|| HttpResponse::Ok().body(STR))),
|
||||||
web::resource("/")
|
),
|
||||||
.route(web::to(|| HttpResponse::Ok().body(STR))),
|
|
||||||
)
|
|
||||||
.into_factory(),
|
|
||||||
|_| AppConfig::default(),
|
|_| AppConfig::default(),
|
||||||
))
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
@ -330,25 +323,23 @@ async fn test_connection_wait_queue_force_close() {
|
|||||||
let num = Arc::new(AtomicUsize::new(0));
|
let num = Arc::new(AtomicUsize::new(0));
|
||||||
let num2 = num.clone();
|
let num2 = num.clone();
|
||||||
|
|
||||||
let srv =
|
let srv = test_server(move || {
|
||||||
test_server(move || {
|
let num2 = num2.clone();
|
||||||
let num2 = num2.clone();
|
pipeline_factory(move |io| {
|
||||||
pipeline_factory(move |io| {
|
num2.fetch_add(1, Ordering::Relaxed);
|
||||||
num2.fetch_add(1, Ordering::Relaxed);
|
ok(io)
|
||||||
ok(io)
|
})
|
||||||
})
|
.and_then(
|
||||||
.and_then(
|
HttpService::new(map_config(
|
||||||
HttpService::new(map_config(
|
App::new().service(
|
||||||
App::new()
|
web::resource("/")
|
||||||
.service(web::resource("/").route(web::to(|| {
|
.route(web::to(|| HttpResponse::Ok().force_close().body(STR))),
|
||||||
HttpResponse::Ok().force_close().body(STR)
|
),
|
||||||
})))
|
|_| AppConfig::default(),
|
||||||
.into_factory(),
|
))
|
||||||
|_| AppConfig::default(),
|
.tcp(),
|
||||||
))
|
)
|
||||||
.tcp(),
|
});
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
let client = awc::Client::build()
|
let client = awc::Client::build()
|
||||||
.connector(awc::Connector::new().limit(1).finish())
|
.connector(awc::Connector::new().limit(1).finish())
|
||||||
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::{map_config, pipeline_factory, IntoServiceFactory, ServiceFactory};
|
use actix_service::{map_config, pipeline_factory, ServiceFactory};
|
||||||
use actix_web::http::Version;
|
use actix_web::http::Version;
|
||||||
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
||||||
use futures::future::ok;
|
use futures::future::ok;
|
||||||
@ -63,11 +63,9 @@ async fn _test_connection_reuse_h2() {
|
|||||||
.and_then(
|
.and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(map_config(
|
.h2(map_config(
|
||||||
App::new()
|
App::new().service(
|
||||||
.service(
|
web::resource("/").route(web::to(|| HttpResponse::Ok())),
|
||||||
web::resource("/").route(web::to(|| HttpResponse::Ok())),
|
),
|
||||||
)
|
|
||||||
.into_factory(),
|
|
||||||
|_| AppConfig::default(),
|
|_| AppConfig::default(),
|
||||||
))
|
))
|
||||||
.openssl(ssl_acceptor())
|
.openssl(ssl_acceptor())
|
||||||
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::{map_config, pipeline_factory, IntoServiceFactory, ServiceFactory};
|
use actix_service::{map_config, pipeline_factory, ServiceFactory};
|
||||||
use actix_web::http::Version;
|
use actix_web::http::Version;
|
||||||
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
||||||
use futures::future::ok;
|
use futures::future::ok;
|
||||||
@ -45,11 +45,9 @@ async fn test_connection_reuse_h2() {
|
|||||||
.and_then(
|
.and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(map_config(
|
.h2(map_config(
|
||||||
App::new()
|
App::new().service(
|
||||||
.service(
|
web::resource("/").route(web::to(|| HttpResponse::Ok())),
|
||||||
web::resource("/").route(web::to(|| HttpResponse::Ok())),
|
),
|
||||||
)
|
|
||||||
.into_factory(),
|
|
||||||
|_| AppConfig::default(),
|
|_| AppConfig::default(),
|
||||||
))
|
))
|
||||||
.openssl(ssl_acceptor())
|
.openssl(ssl_acceptor())
|
||||||
|
@ -42,6 +42,6 @@ async fn main() -> std::io::Result<()> {
|
|||||||
})
|
})
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("127.0.0.1:8080")?
|
||||||
.workers(1)
|
.workers(1)
|
||||||
.start()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
})
|
})
|
||||||
.bind_uds("/Users/fafhrd91/uds-test")?
|
.bind_uds("/Users/fafhrd91/uds-test")?
|
||||||
.workers(1)
|
.workers(1)
|
||||||
.start()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
46
src/data.rs
46
src/data.rs
@ -136,10 +136,11 @@ impl<T: 'static> DataFactory for Data<T> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::http::StatusCode;
|
use crate::http::StatusCode;
|
||||||
use crate::test::{init_service, TestRequest};
|
use crate::test::{self, init_service, TestRequest};
|
||||||
use crate::{web, App, HttpResponse};
|
use crate::{web, App, HttpResponse};
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -234,4 +235,47 @@ mod tests {
|
|||||||
let resp = srv.call(req).await.unwrap();
|
let resp = srv.call(req).await.unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_data_drop() {
|
||||||
|
struct TestData(Arc<AtomicUsize>);
|
||||||
|
|
||||||
|
impl TestData {
|
||||||
|
fn new(inner: Arc<AtomicUsize>) -> Self {
|
||||||
|
let _ = inner.fetch_add(1, Ordering::SeqCst);
|
||||||
|
Self(inner)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clone for TestData {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
let inner = self.0.clone();
|
||||||
|
let _ = inner.fetch_add(1, Ordering::SeqCst);
|
||||||
|
Self(inner)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for TestData {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let _ = self.0.fetch_sub(1, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let num = Arc::new(AtomicUsize::new(0));
|
||||||
|
let data = TestData::new(num.clone());
|
||||||
|
assert_eq!(num.load(Ordering::SeqCst), 1);
|
||||||
|
|
||||||
|
let srv = test::start(move || {
|
||||||
|
let data = data.clone();
|
||||||
|
|
||||||
|
App::new()
|
||||||
|
.data(data)
|
||||||
|
.service(web::resource("/").to(|_data: Data<TestData>| async { "ok" }))
|
||||||
|
});
|
||||||
|
|
||||||
|
assert!(srv.get("/").send().await.unwrap().status().is_success());
|
||||||
|
srv.stop().await;
|
||||||
|
|
||||||
|
assert_eq!(num.load(Ordering::SeqCst), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
19
src/lib.rs
19
src/lib.rs
@ -1,4 +1,4 @@
|
|||||||
#![deny(rust_2018_idioms, warnings)]
|
#![warn(rust_2018_idioms, warnings)]
|
||||||
#: This module
|
//! * [web](web/index.html): This module
|
||||||
//! provide essentials helper functions and types for application registration.
|
//! provides essential helper functions and types for application registration.
|
||||||
//!
|
//!
|
||||||
//! * [HttpRequest](struct.HttpRequest.html) and
|
//! * [HttpRequest](struct.HttpRequest.html) and
|
||||||
//! [HttpResponse](struct.HttpResponse.html): These structs
|
//! [HttpResponse](struct.HttpResponse.html): These structs
|
||||||
@ -151,12 +151,13 @@ pub mod dev {
|
|||||||
pub use actix_server::Server;
|
pub use actix_server::Server;
|
||||||
pub use actix_service::{Service, Transform};
|
pub use actix_service::{Service, Transform};
|
||||||
|
|
||||||
pub(crate) fn insert_slash(path: &str) -> String {
|
pub(crate) fn insert_slash(mut patterns: Vec<String>) -> Vec<String> {
|
||||||
let mut path = path.to_owned();
|
for path in &mut patterns {
|
||||||
if !path.is_empty() && !path.starts_with('/') {
|
if !path.is_empty() && !path.starts_with('/') {
|
||||||
path.insert(0, '/');
|
path.insert(0, '/');
|
||||||
};
|
};
|
||||||
path
|
}
|
||||||
|
patterns
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::http::header::ContentEncoding;
|
use crate::http::header::ContentEncoding;
|
||||||
|
@ -150,7 +150,7 @@ where
|
|||||||
}
|
}
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ where
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.boxed_local()
|
.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +206,14 @@ impl HttpRequest {
|
|||||||
&self.0.config
|
&self.0.config
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an application data stored with `App::extension()` method during
|
/// Get an application data object stored with `App::data` or `App::app_data`
|
||||||
/// application configuration.
|
/// methods during application configuration.
|
||||||
|
///
|
||||||
|
/// If `App::data` was used to store object, use `Data<T>`:
|
||||||
|
///
|
||||||
|
/// ```rust,ignore
|
||||||
|
/// let opt_t = req.app_data::<Data<T>>();
|
||||||
|
/// ```
|
||||||
pub fn app_data<T: 'static>(&self) -> Option<&T> {
|
pub fn app_data<T: 'static>(&self) -> Option<&T> {
|
||||||
if let Some(st) = self.0.app_data.get::<T>() {
|
if let Some(st) = self.0.app_data.get::<T>() {
|
||||||
Some(&st)
|
Some(&st)
|
||||||
|
@ -6,6 +6,7 @@ use std::rc::Rc;
|
|||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_http::{Error, Extensions, Response};
|
use actix_http::{Error, Extensions, Response};
|
||||||
|
use actix_router::IntoPattern;
|
||||||
use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
||||||
@ -48,7 +49,7 @@ type HttpNewService = BoxServiceFactory<(), ServiceRequest, ServiceResponse, Err
|
|||||||
/// Default behavior could be overriden with `default_resource()` method.
|
/// Default behavior could be overriden with `default_resource()` method.
|
||||||
pub struct Resource<T = ResourceEndpoint> {
|
pub struct Resource<T = ResourceEndpoint> {
|
||||||
endpoint: T,
|
endpoint: T,
|
||||||
rdef: String,
|
rdef: Vec<String>,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
routes: Vec<Route>,
|
routes: Vec<Route>,
|
||||||
data: Option<Extensions>,
|
data: Option<Extensions>,
|
||||||
@ -58,12 +59,12 @@ pub struct Resource<T = ResourceEndpoint> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Resource {
|
impl Resource {
|
||||||
pub fn new(path: &str) -> Resource {
|
pub fn new<T: IntoPattern>(path: T) -> Resource {
|
||||||
let fref = Rc::new(RefCell::new(None));
|
let fref = Rc::new(RefCell::new(None));
|
||||||
|
|
||||||
Resource {
|
Resource {
|
||||||
routes: Vec::new(),
|
routes: Vec::new(),
|
||||||
rdef: path.to_string(),
|
rdef: path.patterns(),
|
||||||
name: None,
|
name: None,
|
||||||
endpoint: ResourceEndpoint::new(fref.clone()),
|
endpoint: ResourceEndpoint::new(fref.clone()),
|
||||||
factory_ref: fref,
|
factory_ref: fref,
|
||||||
@ -381,9 +382,9 @@ where
|
|||||||
Some(std::mem::replace(&mut self.guards, Vec::new()))
|
Some(std::mem::replace(&mut self.guards, Vec::new()))
|
||||||
};
|
};
|
||||||
let mut rdef = if config.is_root() || !self.rdef.is_empty() {
|
let mut rdef = if config.is_root() || !self.rdef.is_empty() {
|
||||||
ResourceDef::new(&insert_slash(&self.rdef))
|
ResourceDef::new(insert_slash(self.rdef.clone()))
|
||||||
} else {
|
} else {
|
||||||
ResourceDef::new(&self.rdef)
|
ResourceDef::new(self.rdef.clone())
|
||||||
};
|
};
|
||||||
if let Some(ref name) = self.name {
|
if let Some(ref name) = self.name {
|
||||||
*rdef.name_mut() = name.clone();
|
*rdef.name_mut() = name.clone();
|
||||||
@ -660,6 +661,23 @@ mod tests {
|
|||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_pattern() {
|
||||||
|
let mut srv = init_service(
|
||||||
|
App::new().service(
|
||||||
|
web::resource(["/test", "/test2"])
|
||||||
|
.to(|| async { Ok::<_, Error>(HttpResponse::Ok()) }),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let req = TestRequest::with_uri("/test").to_request();
|
||||||
|
let resp = call_service(&mut srv, req).await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
let req = TestRequest::with_uri("/test2").to_request();
|
||||||
|
let resp = call_service(&mut srv, req).await;
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_default_resource() {
|
async fn test_default_resource() {
|
||||||
let mut srv = init_service(
|
let mut srv = init_service(
|
||||||
|
@ -2,17 +2,19 @@ use std::marker::PhantomData;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::{fmt, io, net};
|
use std::{fmt, io, net};
|
||||||
|
|
||||||
use actix_http::{
|
use actix_http::{body::MessageBody, Error, HttpService, KeepAlive, Request, Response};
|
||||||
body::MessageBody, Error, HttpService, KeepAlive, Protocol, Request, Response,
|
|
||||||
};
|
|
||||||
use actix_server::{Server, ServerBuilder};
|
use actix_server::{Server, ServerBuilder};
|
||||||
use actix_service::{
|
use actix_service::{map_config, IntoServiceFactory, Service, ServiceFactory};
|
||||||
map_config, pipeline_factory, IntoServiceFactory, Service, ServiceFactory,
|
|
||||||
};
|
|
||||||
use futures::future::ok;
|
|
||||||
|
|
||||||
use net2::TcpBuilder;
|
use net2::TcpBuilder;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
use actix_http::Protocol;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use actix_service::pipeline_factory;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use futures::future::ok;
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
||||||
#[cfg(feature = "rustls")]
|
#[cfg(feature = "rustls")]
|
||||||
@ -36,21 +38,17 @@ struct Config {
|
|||||||
///
|
///
|
||||||
/// Create new http server with application factory.
|
/// Create new http server with application factory.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust,no_run
|
||||||
/// use std::io;
|
|
||||||
/// use actix_web::{web, App, HttpResponse, HttpServer};
|
/// use actix_web::{web, App, HttpResponse, HttpServer};
|
||||||
///
|
///
|
||||||
/// fn main() -> io::Result<()> {
|
/// #[actix_rt::main]
|
||||||
/// let sys = actix_rt::System::new("example"); // <- create Actix runtime
|
/// async fn main() -> std::io::Result<()> {
|
||||||
///
|
|
||||||
/// HttpServer::new(
|
/// HttpServer::new(
|
||||||
/// || App::new()
|
/// || App::new()
|
||||||
/// .service(web::resource("/").to(|| HttpResponse::Ok())))
|
/// .service(web::resource("/").to(|| HttpResponse::Ok())))
|
||||||
/// .bind("127.0.0.1:59090")?
|
/// .bind("127.0.0.1:59090")?
|
||||||
/// .start();
|
/// .run()
|
||||||
///
|
/// .await
|
||||||
/// # actix_rt::System::current().stop();
|
|
||||||
/// sys.run()
|
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct HttpServer<F, I, S, B>
|
pub struct HttpServer<F, I, S, B>
|
||||||
@ -260,7 +258,7 @@ where
|
|||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.local_addr(addr)
|
.local_addr(addr)
|
||||||
.finish(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.finish(map_config(factory(), move |_| cfg.clone()))
|
||||||
.tcp()
|
.tcp()
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
@ -307,7 +305,7 @@ where
|
|||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.client_disconnect(c.client_shutdown)
|
.client_disconnect(c.client_shutdown)
|
||||||
.finish(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.finish(map_config(factory(), move |_| cfg.clone()))
|
||||||
.openssl(acceptor.clone())
|
.openssl(acceptor.clone())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
@ -354,7 +352,7 @@ where
|
|||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.client_disconnect(c.client_shutdown)
|
.client_disconnect(c.client_shutdown)
|
||||||
.finish(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.finish(map_config(factory(), move |_| cfg.clone()))
|
||||||
.rustls(config.clone())
|
.rustls(config.clone())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
@ -477,9 +475,7 @@ where
|
|||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.finish(map_config(factory().into_factory(), move |_| {
|
.finish(map_config(factory(), move |_| config.clone())),
|
||||||
config.clone()
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
Ok(self)
|
Ok(self)
|
||||||
@ -521,9 +517,7 @@ where
|
|||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
.finish(map_config(factory().into_factory(), move |_| {
|
.finish(map_config(factory(), move |_| config.clone())),
|
||||||
config.clone()
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
@ -559,11 +553,11 @@ where
|
|||||||
/// async fn main() -> io::Result<()> {
|
/// async fn main() -> io::Result<()> {
|
||||||
/// HttpServer::new(|| App::new().service(web::resource("/").to(|| HttpResponse::Ok())))
|
/// HttpServer::new(|| App::new().service(web::resource("/").to(|| HttpResponse::Ok())))
|
||||||
/// .bind("127.0.0.1:0")?
|
/// .bind("127.0.0.1:0")?
|
||||||
/// .start()
|
/// .run()
|
||||||
/// .await
|
/// .await
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn start(self) -> Server {
|
pub fn run(self) -> Server {
|
||||||
self.builder.start()
|
self.builder.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use actix_http::{
|
|||||||
Error, Extensions, HttpMessage, Payload, PayloadStream, RequestHead, Response,
|
Error, Extensions, HttpMessage, Payload, PayloadStream, RequestHead, Response,
|
||||||
ResponseHead,
|
ResponseHead,
|
||||||
};
|
};
|
||||||
use actix_router::{Path, Resource, ResourceDef, Url};
|
use actix_router::{IntoPattern, Path, Resource, ResourceDef, Url};
|
||||||
use actix_service::{IntoServiceFactory, ServiceFactory};
|
use actix_service::{IntoServiceFactory, ServiceFactory};
|
||||||
|
|
||||||
use crate::config::{AppConfig, AppService};
|
use crate::config::{AppConfig, AppService};
|
||||||
@ -422,16 +422,16 @@ impl<B: MessageBody> fmt::Debug for ServiceResponse<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct WebService {
|
pub struct WebService {
|
||||||
rdef: String,
|
rdef: Vec<String>,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
guards: Vec<Box<dyn Guard>>,
|
guards: Vec<Box<dyn Guard>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebService {
|
impl WebService {
|
||||||
/// Create new `WebService` instance.
|
/// Create new `WebService` instance.
|
||||||
pub fn new(path: &str) -> Self {
|
pub fn new<T: IntoPattern>(path: T) -> Self {
|
||||||
WebService {
|
WebService {
|
||||||
rdef: path.to_string(),
|
rdef: path.patterns(),
|
||||||
name: None,
|
name: None,
|
||||||
guards: Vec::new(),
|
guards: Vec::new(),
|
||||||
}
|
}
|
||||||
@ -491,7 +491,7 @@ impl WebService {
|
|||||||
|
|
||||||
struct WebServiceImpl<T> {
|
struct WebServiceImpl<T> {
|
||||||
srv: T,
|
srv: T,
|
||||||
rdef: String,
|
rdef: Vec<String>,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
guards: Vec<Box<dyn Guard>>,
|
guards: Vec<Box<dyn Guard>>,
|
||||||
}
|
}
|
||||||
@ -514,9 +514,9 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut rdef = if config.is_root() || !self.rdef.is_empty() {
|
let mut rdef = if config.is_root() || !self.rdef.is_empty() {
|
||||||
ResourceDef::new(&insert_slash(&self.rdef))
|
ResourceDef::new(insert_slash(self.rdef))
|
||||||
} else {
|
} else {
|
||||||
ResourceDef::new(&self.rdef)
|
ResourceDef::new(self.rdef)
|
||||||
};
|
};
|
||||||
if let Some(ref name) = self.name {
|
if let Some(ref name) = self.name {
|
||||||
*rdef.name_mut() = name.clone();
|
*rdef.name_mut() = name.clone();
|
||||||
|
72
src/test.rs
72
src/test.rs
@ -11,8 +11,7 @@ use actix_http::http::{Error as HttpError, Method, StatusCode, Uri, Version};
|
|||||||
use actix_http::test::TestRequest as HttpTestRequest;
|
use actix_http::test::TestRequest as HttpTestRequest;
|
||||||
use actix_http::{cookie::Cookie, ws, Extensions, HttpService, Request};
|
use actix_http::{cookie::Cookie, ws, Extensions, HttpService, Request};
|
||||||
use actix_router::{Path, ResourceDef, Url};
|
use actix_router::{Path, ResourceDef, Url};
|
||||||
use actix_rt::System;
|
use actix_rt::{time::delay_for, System};
|
||||||
use actix_server::Server;
|
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
map_config, IntoService, IntoServiceFactory, Service, ServiceFactory,
|
map_config, IntoService, IntoServiceFactory, Service, ServiceFactory,
|
||||||
};
|
};
|
||||||
@ -30,7 +29,7 @@ pub use actix_http::test::TestBuffer;
|
|||||||
|
|
||||||
use crate::config::AppConfig;
|
use crate::config::AppConfig;
|
||||||
use crate::data::Data;
|
use crate::data::Data;
|
||||||
use crate::dev::{Body, MessageBody, Payload};
|
use crate::dev::{Body, MessageBody, Payload, Server};
|
||||||
use crate::request::HttpRequestPool;
|
use crate::request::HttpRequestPool;
|
||||||
use crate::rmap::ResourceMap;
|
use crate::rmap::ResourceMap;
|
||||||
use crate::service::{ServiceRequest, ServiceResponse};
|
use crate::service::{ServiceRequest, ServiceResponse};
|
||||||
@ -66,7 +65,7 @@ pub fn default_service(
|
|||||||
/// let mut app = test::init_service(
|
/// let mut app = test::init_service(
|
||||||
/// App::new()
|
/// App::new()
|
||||||
/// .service(web::resource("/test").to(|| async { HttpResponse::Ok() }))
|
/// .service(web::resource("/test").to(|| async { HttpResponse::Ok() }))
|
||||||
/// );
|
/// ).await;
|
||||||
///
|
///
|
||||||
/// // Create request object
|
/// // Create request object
|
||||||
/// let req = test::TestRequest::with_uri("/test").to_request();
|
/// let req = test::TestRequest::with_uri("/test").to_request();
|
||||||
@ -627,14 +626,14 @@ where
|
|||||||
let ctimeout = cfg.client_timeout;
|
let ctimeout = cfg.client_timeout;
|
||||||
let builder = Server::build().workers(1).disable_signals();
|
let builder = Server::build().workers(1).disable_signals();
|
||||||
|
|
||||||
match cfg.stream {
|
let srv = match cfg.stream {
|
||||||
StreamType::Tcp => match cfg.tp {
|
StreamType::Tcp => match cfg.tp {
|
||||||
HttpVer::Http1 => builder.listen("test", tcp, move || {
|
HttpVer::Http1 => builder.listen("test", tcp, move || {
|
||||||
let cfg =
|
let cfg =
|
||||||
AppConfig::new(false, local_addr, format!("{}", local_addr));
|
AppConfig::new(false, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.h1(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.h1(map_config(factory(), move |_| cfg.clone()))
|
||||||
.tcp()
|
.tcp()
|
||||||
}),
|
}),
|
||||||
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
||||||
@ -642,7 +641,7 @@ where
|
|||||||
AppConfig::new(false, local_addr, format!("{}", local_addr));
|
AppConfig::new(false, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.h2(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.h2(map_config(factory(), move |_| cfg.clone()))
|
||||||
.tcp()
|
.tcp()
|
||||||
}),
|
}),
|
||||||
HttpVer::Both => builder.listen("test", tcp, move || {
|
HttpVer::Both => builder.listen("test", tcp, move || {
|
||||||
@ -650,9 +649,7 @@ where
|
|||||||
AppConfig::new(false, local_addr, format!("{}", local_addr));
|
AppConfig::new(false, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.finish(map_config(factory().into_factory(), move |_| {
|
.finish(map_config(factory(), move |_| cfg.clone()))
|
||||||
cfg.clone()
|
|
||||||
}))
|
|
||||||
.tcp()
|
.tcp()
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -663,7 +660,7 @@ where
|
|||||||
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.h1(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.h1(map_config(factory(), move |_| cfg.clone()))
|
||||||
.openssl(acceptor.clone())
|
.openssl(acceptor.clone())
|
||||||
}),
|
}),
|
||||||
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
||||||
@ -671,7 +668,7 @@ where
|
|||||||
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.h2(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.h2(map_config(factory(), move |_| cfg.clone()))
|
||||||
.openssl(acceptor.clone())
|
.openssl(acceptor.clone())
|
||||||
}),
|
}),
|
||||||
HttpVer::Both => builder.listen("test", tcp, move || {
|
HttpVer::Both => builder.listen("test", tcp, move || {
|
||||||
@ -679,9 +676,7 @@ where
|
|||||||
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.finish(map_config(factory().into_factory(), move |_| {
|
.finish(map_config(factory(), move |_| cfg.clone()))
|
||||||
cfg.clone()
|
|
||||||
}))
|
|
||||||
.openssl(acceptor.clone())
|
.openssl(acceptor.clone())
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -692,7 +687,7 @@ where
|
|||||||
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.h1(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.h1(map_config(factory(), move |_| cfg.clone()))
|
||||||
.rustls(config.clone())
|
.rustls(config.clone())
|
||||||
}),
|
}),
|
||||||
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
||||||
@ -700,7 +695,7 @@ where
|
|||||||
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.h2(map_config(factory().into_factory(), move |_| cfg.clone()))
|
.h2(map_config(factory(), move |_| cfg.clone()))
|
||||||
.rustls(config.clone())
|
.rustls(config.clone())
|
||||||
}),
|
}),
|
||||||
HttpVer::Both => builder.listen("test", tcp, move || {
|
HttpVer::Both => builder.listen("test", tcp, move || {
|
||||||
@ -708,9 +703,7 @@ where
|
|||||||
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
AppConfig::new(true, local_addr, format!("{}", local_addr));
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.client_timeout(ctimeout)
|
.client_timeout(ctimeout)
|
||||||
.finish(map_config(factory().into_factory(), move |_| {
|
.finish(map_config(factory(), move |_| cfg.clone()))
|
||||||
cfg.clone()
|
|
||||||
}))
|
|
||||||
.rustls(config.clone())
|
.rustls(config.clone())
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -718,11 +711,11 @@ where
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
tx.send((System::current(), local_addr)).unwrap();
|
tx.send((System::current(), srv, local_addr)).unwrap();
|
||||||
sys.run()
|
sys.run()
|
||||||
});
|
});
|
||||||
|
|
||||||
let (system, addr) = rx.recv().unwrap();
|
let (system, server, addr) = rx.recv().unwrap();
|
||||||
|
|
||||||
let client = {
|
let client = {
|
||||||
let connector = {
|
let connector = {
|
||||||
@ -737,7 +730,7 @@ where
|
|||||||
.map_err(|e| log::error!("Can not set alpn protocol: {:?}", e));
|
.map_err(|e| log::error!("Can not set alpn protocol: {:?}", e));
|
||||||
Connector::new()
|
Connector::new()
|
||||||
.conn_lifetime(time::Duration::from_secs(0))
|
.conn_lifetime(time::Duration::from_secs(0))
|
||||||
.timeout(time::Duration::from_millis(3000))
|
.timeout(time::Duration::from_millis(30000))
|
||||||
.ssl(builder.build())
|
.ssl(builder.build())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
@ -745,7 +738,7 @@ where
|
|||||||
{
|
{
|
||||||
Connector::new()
|
Connector::new()
|
||||||
.conn_lifetime(time::Duration::from_secs(0))
|
.conn_lifetime(time::Duration::from_secs(0))
|
||||||
.timeout(time::Duration::from_millis(3000))
|
.timeout(time::Duration::from_millis(30000))
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -758,6 +751,7 @@ where
|
|||||||
addr,
|
addr,
|
||||||
client,
|
client,
|
||||||
system,
|
system,
|
||||||
|
server,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -854,6 +848,7 @@ pub struct TestServer {
|
|||||||
client: awc::Client,
|
client: awc::Client,
|
||||||
system: actix_rt::System,
|
system: actix_rt::System,
|
||||||
ssl: bool,
|
ssl: bool,
|
||||||
|
server: Server,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestServer {
|
impl TestServer {
|
||||||
@ -942,15 +937,17 @@ impl TestServer {
|
|||||||
self.ws_at("/").await
|
self.ws_at("/").await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stop http server
|
/// Gracefully stop http server
|
||||||
fn stop(&mut self) {
|
pub async fn stop(self) {
|
||||||
|
self.server.stop(true).await;
|
||||||
self.system.stop();
|
self.system.stop();
|
||||||
|
delay_for(time::Duration::from_millis(100)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for TestServer {
|
impl Drop for TestServer {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.stop()
|
self.system.stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,7 +959,7 @@ mod tests {
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{http::header, web, App, HttpResponse};
|
use crate::{http::header, web, App, HttpResponse, Responder};
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_basics() {
|
async fn test_basics() {
|
||||||
@ -1148,6 +1145,25 @@ mod tests {
|
|||||||
assert!(res.status().is_success());
|
assert!(res.status().is_success());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_server_data() {
|
||||||
|
async fn handler(data: web::Data<usize>) -> impl Responder {
|
||||||
|
assert_eq!(**data, 10);
|
||||||
|
HttpResponse::Ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut app = init_service(
|
||||||
|
App::new()
|
||||||
|
.data(10usize)
|
||||||
|
.service(web::resource("/index.html").to(handler)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let req = TestRequest::post().uri("/index.html").to_request();
|
||||||
|
let res = app.call(req).await.unwrap();
|
||||||
|
assert!(res.status().is_success());
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_actor() {
|
async fn test_actor() {
|
||||||
use actix::Actor;
|
use actix::Actor;
|
||||||
|
@ -365,7 +365,7 @@ where
|
|||||||
.map_err(|_| UrlencodedError::Parse)
|
.map_err(|_| UrlencodedError::Parse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.boxed_local(),
|
.boxed_local(),
|
||||||
);
|
);
|
||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ where
|
|||||||
}
|
}
|
||||||
Ok(serde_json::from_slice::<U>(&body)?)
|
Ok(serde_json::from_slice::<U>(&body)?)
|
||||||
}
|
}
|
||||||
.boxed_local(),
|
.boxed_local(),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
|
@ -229,7 +229,7 @@ impl FromRequest for String {
|
|||||||
.ok_or_else(|| ErrorBadRequest("Can not decode body"))?)
|
.ok_or_else(|| ErrorBadRequest("Can not decode body"))?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.boxed_local(),
|
.boxed_local(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ impl Future for HttpMessageBody {
|
|||||||
}
|
}
|
||||||
Ok(body.freeze())
|
Ok(body.freeze())
|
||||||
}
|
}
|
||||||
.boxed_local(),
|
.boxed_local(),
|
||||||
);
|
);
|
||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
//! Essentials helper functions and types for application registration.
|
//! Essentials helper functions and types for application registration.
|
||||||
use actix_http::http::Method;
|
use actix_http::http::Method;
|
||||||
|
use actix_router::IntoPattern;
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
|
|
||||||
pub use actix_http::Response as HttpResponse;
|
pub use actix_http::Response as HttpResponse;
|
||||||
@ -50,7 +51,7 @@ pub use crate::types::*;
|
|||||||
/// .route(web::head().to(|| HttpResponse::MethodNotAllowed()))
|
/// .route(web::head().to(|| HttpResponse::MethodNotAllowed()))
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub fn resource(path: &str) -> Resource {
|
pub fn resource<T: IntoPattern>(path: T) -> Resource {
|
||||||
Resource::new(path)
|
Resource::new(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +250,7 @@ where
|
|||||||
/// .finish(my_service)
|
/// .finish(my_service)
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub fn service(path: &str) -> WebService {
|
pub fn service<T: IntoPattern>(path: T) -> WebService {
|
||||||
WebService::new(path)
|
WebService::new(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ default = []
|
|||||||
openssl = ["open-ssl", "awc/openssl"]
|
openssl = ["open-ssl", "awc/openssl"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.1"
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
actix-connect = "1.0.0"
|
actix-connect = "1.0.0"
|
||||||
actix-utils = "1.0.3"
|
actix-utils = "1.0.3"
|
||||||
|
@ -77,7 +77,7 @@ pub fn test_server<F: ServiceFactory<TcpStream>>(factory: F) -> TestServer {
|
|||||||
.map_err(|e| log::error!("Can not set alpn protocol: {:?}", e));
|
.map_err(|e| log::error!("Can not set alpn protocol: {:?}", e));
|
||||||
Connector::new()
|
Connector::new()
|
||||||
.conn_lifetime(time::Duration::from_secs(0))
|
.conn_lifetime(time::Duration::from_secs(0))
|
||||||
.timeout(time::Duration::from_millis(3000))
|
.timeout(time::Duration::from_millis(30000))
|
||||||
.ssl(builder.build())
|
.ssl(builder.build())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ pub fn test_server<F: ServiceFactory<TcpStream>>(factory: F) -> TestServer {
|
|||||||
{
|
{
|
||||||
Connector::new()
|
Connector::new()
|
||||||
.conn_lifetime(time::Duration::from_secs(0))
|
.conn_lifetime(time::Duration::from_secs(0))
|
||||||
.timeout(time::Duration::from_millis(3000))
|
.timeout(time::Duration::from_millis(30000))
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ async fn test_start() {
|
|||||||
.disable_signals()
|
.disable_signals()
|
||||||
.bind(format!("{}", addr))
|
.bind(format!("{}", addr))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.start();
|
.run();
|
||||||
|
|
||||||
let _ = tx.send((srv, actix_rt::System::current()));
|
let _ = tx.send((srv, actix_rt::System::current()));
|
||||||
let _ = sys.run();
|
let _ = sys.run();
|
||||||
@ -111,7 +111,7 @@ async fn test_start_ssl() {
|
|||||||
.disable_signals()
|
.disable_signals()
|
||||||
.bind_openssl(format!("{}", addr), builder)
|
.bind_openssl(format!("{}", addr), builder)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.start();
|
.run();
|
||||||
|
|
||||||
let _ = tx.send((srv, actix_rt::System::current()));
|
let _ = tx.send((srv, actix_rt::System::current()));
|
||||||
let _ = sys.run();
|
let _ = sys.run();
|
||||||
|
Reference in New Issue
Block a user