diff --git a/CHANGES.md b/CHANGES.md index 1779af9ee..995ef884a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,10 @@ ## Unreleased - 2020-xx-xx +## 3.0.0 - 2020-09-11 +* No significant changes from `3.0.0-beta.4`. + + ## 3.0.0-beta.4 - 2020-09-09 ### Added * `middleware::NormalizePath` now has configurable behaviour for either always having a trailing diff --git a/Cargo.toml b/Cargo.toml index 11559bcae..ce33097be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "3.0.0-beta.4" +version = "3.0.0" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" @@ -76,9 +76,9 @@ actix-macros = "0.1.0" actix-threadpool = "0.3.1" actix-tls = "2.0.0" -actix-web-codegen = "0.3.0-beta.1" -actix-http = "2.0.0-beta.4" -awc = { version = "2.0.0-beta.4", default-features = false } +actix-web-codegen = "0.3.0" +actix-http = "2.0.0" +awc = { version = "2.0.0", default-features = false } bytes = "0.5.3" derive_more = "0.99.2" @@ -92,7 +92,7 @@ mime = "0.3" socket2 = "0.3" pin-project = "0.4.17" regex = "1.3" -serde = { version = "1.0", features=["derive"] } +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_urlencoded = "0.6.1" time = { version = "0.2.7", default-features = false, features = ["std"] } @@ -102,7 +102,8 @@ rust-tls = { package = "rustls", version = "0.18.0", optional = true } tinyvec = { version = "0.3", features = ["alloc"] } [dev-dependencies] -actix = "0.10.0-alpha.1" +actix = "0.10.0" +actix-http = { version = "2.0.0-beta.4", features = ["actors"] } rand = "0.7" env_logger = "0.7" serde_derive = "1.0" diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 6cdf2d16c..8f5ba39b8 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2017-NOW Nikolay Kim + Copyright 2017-NOW Actix Team Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/LICENSE-MIT b/LICENSE-MIT index 0f80296ae..95938ef15 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2017 Nikolay Kim +Copyright (c) 2017 Actix Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/MIGRATION.md b/MIGRATION.md index 15045ed69..fd940651f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,5 +1,8 @@ ## Unreleased + +## 3.0.0 + * Setting a cookie's SameSite property, explicitly, to `SameSite::None` will now result in `SameSite=None` being sent with the response Set-Cookie header. To create a cookie without a SameSite attribute, remove any calls setting same_site. @@ -40,6 +43,7 @@ * `HttpServer::maxconnrate` is renamed to the more expressive `HttpServer::max_connection_rate`. + ## 2.0.0 * `HttpServer::start()` renamed to `HttpServer::run()`. It also possible to diff --git a/README.md b/README.md index 48f9d1442..3e3ce8bf1 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,6 @@ ## Example -

- WARNING: This example is for the master branch which is currently in beta stages for v3. For - Actix web v2 see the getting started guide. -

- Dependencies: ```toml diff --git a/actix-cors/README.md b/actix-cors/README.md deleted file mode 100644 index c860ec5ae..000000000 --- a/actix-cors/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Cors Middleware for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-cors)](https://crates.io/crates/actix-cors) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -**This crate moved to https://github.com/actix/actix-extras.** - -## Documentation & community resources - -* [User Guide](https://actix.rs/docs/) -* [API Documentation](https://docs.rs/actix-cors/) -* [Chat on gitter](https://gitter.im/actix/actix) -* Cargo package: [actix-cors](https://crates.io/crates/actix-cors) -* Minimum supported Rust version: 1.34 or later diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 4c6441324..8841f7fb1 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.3.0-beta.1" +version = "0.3.0" authors = ["Nikolay Kim "] description = "Static files support for actix web." readme = "README.md" @@ -17,9 +17,9 @@ name = "actix_files" path = "src/lib.rs" [dependencies] -actix-web = { version = "3.0.0-beta.4", default-features = false } -actix-http = "2.0.0-beta.4" -actix-service = "1.0.1" +actix-web = { version = "3.0.0", default-features = false } +actix-http = "2.0.0" +actix-service = "1.0.6" bitflags = "1" bytes = "0.5.3" futures-core = { version = "0.3.5", default-features = false } @@ -33,4 +33,4 @@ v_htmlescape = "0.10" [dev-dependencies] actix-rt = "1.0.0" -actix-web = { version = "3.0.0-beta.4", features = ["openssl"] } +actix-web = { version = "3.0.0", features = ["openssl"] } diff --git a/actix-framed/README.md b/actix-framed/README.md deleted file mode 100644 index a4eaadf21..000000000 --- a/actix-framed/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Framed app for actix web - -**This crate has been deprecated and removed.** diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index dfa55e7f1..6a98c4ca7 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -3,6 +3,10 @@ ## Unreleased - 2020-xx-xx +## 2.0.0 - 2020-09-11 +* No significant changes from `2.0.0-beta.4`. + + ## 2.0.0-beta.4 - 2020-09-09 ### Changed * Update actix-codec and actix-utils dependencies. diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 6d8d143ed..0bbde881d 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "2.0.0-beta.4" +version = "2.0.0" authors = ["Nikolay Kim "] description = "Actix HTTP primitives" readme = "README.md" @@ -40,14 +40,14 @@ secure-cookies = ["cookie/secure"] actors = ["actix"] [dependencies] -actix-service = "1.0.5" +actix-service = "1.0.6" actix-codec = "0.3.0" actix-connect = "2.0.0" actix-utils = "2.0.0" actix-rt = "1.0.0" actix-threadpool = "0.3.1" actix-tls = { version = "2.0.0", optional = true } -actix = { version = "0.10.0-alpha.1", optional = true } +actix = { version = "0.10.0", optional = true } base64 = "0.12" bitflags = "1.2" @@ -88,7 +88,7 @@ flate2 = { version = "1.0.13", optional = true } [dev-dependencies] actix-server = "1.0.1" actix-connect = { version = "2.0.0", features = ["openssl"] } -actix-http-test = { version = "2.0.0-alpha.1", features = ["openssl"] } +actix-http-test = { version = "2.0.0", features = ["openssl"] } actix-tls = { version = "2.0.0", features = ["openssl"] } criterion = "0.3" env_logger = "0.7" diff --git a/actix-http/src/header/common/content_disposition.rs b/actix-http/src/header/common/content_disposition.rs index 051dcfe80..37da830ca 100644 --- a/actix-http/src/header/common/content_disposition.rs +++ b/actix-http/src/header/common/content_disposition.rs @@ -283,11 +283,11 @@ impl DispositionParam { /// Some("\u{1f600}.svg".as_bytes())); /// ``` /// -/// # WARN +/// # Security Note +/// /// If "filename" parameter is supplied, do not use the file name blindly, check and possibly /// change to match local file system conventions if applicable, and do not use directory path -/// information that may be present. See [RFC2183](https://tools.ietf.org/html/rfc2183#section-2.3) -/// . +/// information that may be present. See [RFC2183](https://tools.ietf.org/html/rfc2183#section-2.3). #[derive(Clone, Debug, PartialEq)] pub struct ContentDisposition { /// The disposition type diff --git a/actix-identity/README.md b/actix-identity/README.md deleted file mode 100644 index 62a40137f..000000000 --- a/actix-identity/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Identity service for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-identity)](https://crates.io/crates/actix-identity) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -**This crate moved to https://github.com/actix/actix-extras.** - -## Documentation & community resources - -* [User Guide](https://actix.rs/docs/) -* [API Documentation](https://docs.rs/actix-identity/) -* [Chat on gitter](https://gitter.im/actix/actix) -* Cargo package: [actix-session](https://crates.io/crates/actix-identity) -* Minimum supported Rust version: 1.34 or later diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index 7149f6713..b25053025 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -3,6 +3,10 @@ ## Unreleased - 2020-xx-xx +## 3.0.0 - 2020-09-11 +* No significant changes from `3.0.0-beta.2`. + + ## 3.0.0-beta.2 - 2020-09-10 * Update `actix-*` dependencies to latest versions. diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 0fd5d0922..e2e9dbf14 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-multipart" -version = "0.3.0-beta.2" +version = "0.3.0" authors = ["Nikolay Kim "] description = "Multipart support for actix web framework." readme = "README.md" @@ -16,8 +16,8 @@ name = "actix_multipart" path = "src/lib.rs" [dependencies] -actix-web = { version = "3.0.0-beta.4", default-features = false } -actix-service = "1.0.1" +actix-web = { version = "3.0.0", default-features = false } +actix-service = "1.0.6" actix-utils = "2.0.0" bytes = "0.5.3" derive_more = "0.99.2" @@ -29,4 +29,4 @@ twoway = "0.2" [dev-dependencies] actix-rt = "1.0.0" -actix-http = "2.0.0-beta.4" +actix-http = "2.0.0" diff --git a/actix-session/README.md b/actix-session/README.md deleted file mode 100644 index 00e580120..000000000 --- a/actix-session/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Session for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-session)](https://crates.io/crates/actix-session) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -**This crate moved to https://github.com/actix/actix-extras.** - -## Documentation & community resources - -* [User Guide](https://actix.rs/docs/) -* [API Documentation](https://docs.rs/actix-session/) -* [Chat on gitter](https://gitter.im/actix/actix) -* Cargo package: [actix-session](https://crates.io/crates/actix-session) -* Minimum supported Rust version: 1.34 or later diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index 4dcd403a3..4b9381a33 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -3,6 +3,10 @@ ## Unreleased - 2020-xx-xx +## 3.0.0 - 2020-09-11 +* No significant changes from `3.0.0-beta.2`. + + ## 3.0.0-beta.2 - 2020-09-10 * Update `actix-*` dependencies to latest versions. diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index cb7fd3a80..2f3c63022 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web-actors" -version = "3.0.0-beta.2" +version = "3.0.0" authors = ["Nikolay Kim "] description = "Actix actors support for actix web framework." readme = "README.md" @@ -16,9 +16,9 @@ name = "actix_web_actors" path = "src/lib.rs" [dependencies] -actix = "0.10.0-alpha.2" -actix-web = { version = "3.0.0-beta.4", default-features = false } -actix-http = "2.0.0-beta.4" +actix = "0.10.0" +actix-web = { version = "3.0.0", default-features = false } +actix-http = "2.0.0" actix-codec = "0.3.0" bytes = "0.5.2" futures-channel = { version = "0.3.5", default-features = false } @@ -26,6 +26,6 @@ futures-core = { version = "0.3.5", default-features = false } pin-project = "0.4.17" [dev-dependencies] -actix-rt = "1.0.0" +actix-rt = "1.1.1" env_logger = "0.7" futures-util = { version = "0.3.5", default-features = false } diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index 242c5f8de..b735be9ce 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -3,6 +3,10 @@ ## Unreleased - 2020-xx-xx +## 0.3.0 - 2020-09-11 +* No significant changes from `0.3.0-beta.1`. + + ## 0.3.0-beta.1 - 2020-07-14 * Add main entry-point macro that uses re-exported runtime. [#1559] diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index ddd886c40..05b52c9db 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web-codegen" -version = "0.3.0-beta.1" +version = "0.3.0" description = "Actix web proc macros" readme = "README.md" homepage = "https://actix.rs" @@ -20,5 +20,5 @@ proc-macro2 = "1" [dev-dependencies] actix-rt = "1.0.0" -actix-web = "3.0.0-beta.4" +actix-web = "3.0.0" futures-util = { version = "0.3.5", default-features = false } diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 4a830b8fc..07a469746 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -3,6 +3,11 @@ ## Unreleased - 2020-xx-xx +## 2.0.0 - 2020-09-11 +### Changed +* `Client::build` was renamed to `Client::builder`. + + ## 2.0.0-beta.4 - 2020-09-09 ### Changed * Update actix-codec & actix-tls dependencies. diff --git a/awc/Cargo.toml b/awc/Cargo.toml index b55f4dabb..c67b6ba6f 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awc" -version = "2.0.0-beta.4" +version = "2.0.0" authors = ["Nikolay Kim "] description = "Async HTTP client library that uses the Actix runtime." readme = "README.md" @@ -38,8 +38,8 @@ compress = ["actix-http/compress"] [dependencies] actix-codec = "0.3.0" -actix-service = "1.0.1" -actix-http = "2.0.0-beta.4" +actix-service = "1.0.6" +actix-http = "2.0.0" actix-rt = "1.0.0" base64 = "0.12" @@ -58,9 +58,9 @@ rust-tls = { version = "0.18.0", package = "rustls", optional = true, features = [dev-dependencies] actix-connect = { version = "2.0.0", features = ["openssl"] } -actix-web = { version = "3.0.0-beta.4", features = ["openssl"] } -actix-http = { version = "2.0.0-beta.4", features = ["openssl"] } -actix-http-test = { version = "2.0.0-alpha.1", features = ["openssl"] } +actix-web = { version = "3.0.0", features = ["openssl"] } +actix-http = { version = "2.0.0", features = ["openssl"] } +actix-http-test = { version = "2.0.0", features = ["openssl"] } actix-utils = "2.0.0" actix-server = "1.0.0" actix-tls = { version = "2.0.0", features = ["openssl", "rustls"] } diff --git a/awc/src/lib.rs b/awc/src/lib.rs index 4850b78f0..45c52092a 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -166,8 +166,9 @@ impl Client { Client::default() } - /// Build client instance. - pub fn build() -> ClientBuilder { + /// Create `Client` builder. + /// This function is equivalent of `ClientBuilder::new()`. + pub fn builder() -> ClientBuilder { ClientBuilder::new() } diff --git a/awc/src/request.rs b/awc/src/request.rs index c34a8e221..dcada2c6d 100644 --- a/awc/src/request.rs +++ b/awc/src/request.rs @@ -623,7 +623,7 @@ mod tests { #[actix_rt::test] async fn test_client_header() { - let req = Client::build() + let req = Client::builder() .header(header::CONTENT_TYPE, "111") .finish() .get("/"); @@ -641,7 +641,7 @@ mod tests { #[actix_rt::test] async fn test_client_header_override() { - let req = Client::build() + let req = Client::builder() .header(header::CONTENT_TYPE, "111") .finish() .get("/") diff --git a/awc/src/ws.rs b/awc/src/ws.rs index 96687ac74..57e80bd46 100644 --- a/awc/src/ws.rs +++ b/awc/src/ws.rs @@ -434,7 +434,7 @@ mod tests { #[actix_rt::test] async fn test_header_override() { - let req = Client::build() + let req = Client::builder() .header(header::CONTENT_TYPE, "111") .finish() .ws("/") diff --git a/awc/tests/test_client.rs b/awc/tests/test_client.rs index 21be155e8..a9552d0d5 100644 --- a/awc/tests/test_client.rs +++ b/awc/tests/test_client.rs @@ -120,7 +120,7 @@ async fn test_timeout() { .timeout(Duration::from_secs(15)) .finish(); - let client = awc::Client::build() + let client = awc::Client::builder() .connector(connector) .timeout(Duration::from_millis(50)) .finish(); @@ -141,7 +141,7 @@ async fn test_timeout_override() { }))) }); - let client = awc::Client::build() + let client = awc::Client::builder() .timeout(Duration::from_millis(50000)) .finish(); let request = client @@ -291,7 +291,7 @@ async fn test_connection_wait_queue() { }) .await; - let client = awc::Client::build() + let client = awc::Client::builder() .connector(awc::Connector::new().limit(1).finish()) .finish(); @@ -340,7 +340,7 @@ async fn test_connection_wait_queue_force_close() { }) .await; - let client = awc::Client::build() + let client = awc::Client::builder() .connector(awc::Connector::new().limit(1).finish()) .finish(); diff --git a/awc/tests/test_connector.rs b/awc/tests/test_connector.rs index 633ac2d50..888f7a900 100644 --- a/awc/tests/test_connector.rs +++ b/awc/tests/test_connector.rs @@ -47,7 +47,7 @@ async fn test_connection_window_size() { .set_alpn_protos(b"\x02h2\x08http/1.1") .map_err(|e| log::error!("Can not set alpn protocol: {:?}", e)); - let client = awc::Client::build() + let client = awc::Client::builder() .connector(awc::Connector::new().ssl(builder.build()).finish()) .initial_window_size(100) .initial_connection_window_size(100) diff --git a/awc/tests/test_rustls_client.rs b/awc/tests/test_rustls_client.rs index 8fb43c439..0df6b154c 100644 --- a/awc/tests/test_rustls_client.rs +++ b/awc/tests/test_rustls_client.rs @@ -82,7 +82,7 @@ async fn _test_connection_reuse_h2() { .dangerous() .set_certificate_verifier(Arc::new(danger::NoCertificateVerification {})); - let client = awc::Client::build() + let client = awc::Client::builder() .connector(awc::Connector::new().rustls(Arc::new(config)).finish()) .finish(); diff --git a/awc/tests/test_ssl_client.rs b/awc/tests/test_ssl_client.rs index ca65fb248..eced5f14b 100644 --- a/awc/tests/test_ssl_client.rs +++ b/awc/tests/test_ssl_client.rs @@ -62,7 +62,7 @@ async fn test_connection_reuse_h2() { .set_alpn_protos(b"\x02h2\x08http/1.1") .map_err(|e| log::error!("Can not set alpn protocol: {:?}", e)); - let client = awc::Client::build() + let client = awc::Client::builder() .connector(awc::Connector::new().ssl(builder.build()).finish()) .finish(); diff --git a/src/lib.rs b/src/lib.rs index 97141599c..0eced5b42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,7 +59,7 @@ //! * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/)) //! * Includes an async [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html) //! * Supports [Actix actor framework](https://github.com/actix/actix) -//! * Runs on stable Rust 1.41+ +//! * Runs on stable Rust 1.42+ //! //! ## Crate Features //! diff --git a/src/route.rs b/src/route.rs index 3a833bdf3..129a67332 100644 --- a/src/route.rs +++ b/src/route.rs @@ -368,7 +368,7 @@ mod tests { })) .route(web::post().to(|| async { delay_for(Duration::from_millis(100)).await; - HttpResponse::Created() + Ok::<_, ()>(HttpResponse::Created()) })) .route(web::delete().to(|| async { delay_for(Duration::from_millis(100)).await; diff --git a/src/scope.rs b/src/scope.rs index c4b01d266..25b5366d8 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -826,7 +826,7 @@ mod tests { async fn test_scope_variable_segment() { let mut srv = init_service(App::new().service(web::scope("/ab-{project}").service( - web::resource("/path1").to(|r: HttpRequest| async move { + web::resource("/path1").to(|r: HttpRequest| { HttpResponse::Ok() .body(format!("project: {}", &r.match_info()["project"])) }), @@ -926,7 +926,7 @@ mod tests { async fn test_nested_scope_with_variable_segment() { let mut srv = init_service(App::new().service(web::scope("/app").service( web::scope("/{project_id}").service(web::resource("/path1").to( - |r: HttpRequest| async move { + |r: HttpRequest| { HttpResponse::Created() .body(format!("project: {}", &r.match_info()["project_id"])) }, @@ -951,7 +951,7 @@ mod tests { async fn test_nested2_scope_with_variable_segment() { let mut srv = init_service(App::new().service(web::scope("/app").service( web::scope("/{project}").service(web::scope("/{id}").service( - web::resource("/path1").to(|r: HttpRequest| async move { + web::resource("/path1").to(|r: HttpRequest| { HttpResponse::Created().body(format!( "project: {} - {}", &r.match_info()["project"], @@ -1178,7 +1178,7 @@ mod tests { ); s.route( "/", - web::get().to(|req: HttpRequest| async move { + web::get().to(|req: HttpRequest| { HttpResponse::Ok().body( req.url_for("youtube", &["xxxxxx"]).unwrap().to_string(), ) @@ -1199,7 +1199,7 @@ mod tests { async fn test_url_for_nested() { let mut srv = init_service(App::new().service(web::scope("/a").service( web::scope("/b").service(web::resource("/c/{stuff}").name("c").route( - web::get().to(|req: HttpRequest| async move { + web::get().to(|req: HttpRequest| { HttpResponse::Ok() .body(format!("{}", req.url_for("c", &["12345"]).unwrap())) }), diff --git a/src/test.rs b/src/test.rs index 49c5cc214..ee51b71ee 100644 --- a/src/test.rs +++ b/src/test.rs @@ -822,7 +822,7 @@ where } }; - Client::build().connector(connector).finish() + Client::builder().connector(connector).finish() }; TestServer { @@ -1072,14 +1072,9 @@ mod tests { let mut app = init_service( App::new().service( web::resource("/index.html") - .route(web::put().to(|| async { HttpResponse::Ok().body("put!") })) - .route( - web::patch().to(|| async { HttpResponse::Ok().body("patch!") }), - ) - .route( - web::delete() - .to(|| async { HttpResponse::Ok().body("delete!") }), - ), + .route(web::put().to(|| HttpResponse::Ok().body("put!"))) + .route(web::patch().to(|| HttpResponse::Ok().body("patch!"))) + .route(web::delete().to(|| HttpResponse::Ok().body("delete!"))), ), ) .await; @@ -1107,11 +1102,13 @@ mod tests { #[actix_rt::test] async fn test_response() { - let mut app = - init_service(App::new().service(web::resource("/index.html").route( - web::post().to(|| async { HttpResponse::Ok().body("welcome!") }), - ))) - .await; + let mut app = init_service( + App::new().service( + web::resource("/index.html") + .route(web::post().to(|| HttpResponse::Ok().body("welcome!"))), + ), + ) + .await; let req = TestRequest::post() .uri("/index.html") @@ -1124,11 +1121,13 @@ mod tests { #[actix_rt::test] async fn test_send_request() { - let mut app = - init_service(App::new().service(web::resource("/index.html").route( - web::get().to(|| async { HttpResponse::Ok().body("welcome!") }), - ))) - .await; + let mut app = init_service( + App::new().service( + web::resource("/index.html") + .route(web::get().to(|| HttpResponse::Ok().body("welcome!"))), + ), + ) + .await; let resp = TestRequest::get() .uri("/index.html") @@ -1148,7 +1147,7 @@ mod tests { #[actix_rt::test] async fn test_response_json() { let mut app = init_service(App::new().service(web::resource("/people").route( - web::post().to(|person: web::Json| async { + web::post().to(|person: web::Json| { HttpResponse::Ok().json(person.into_inner()) }), ))) @@ -1169,7 +1168,7 @@ mod tests { #[actix_rt::test] async fn test_body_json() { let mut app = init_service(App::new().service(web::resource("/people").route( - web::post().to(|person: web::Json| async { + web::post().to(|person: web::Json| { HttpResponse::Ok().json(person.into_inner()) }), ))) @@ -1191,7 +1190,7 @@ mod tests { #[actix_rt::test] async fn test_request_response_form() { let mut app = init_service(App::new().service(web::resource("/people").route( - web::post().to(|person: web::Form| async { + web::post().to(|person: web::Form| { HttpResponse::Ok().json(person.into_inner()) }), ))) @@ -1217,7 +1216,7 @@ mod tests { #[actix_rt::test] async fn test_request_response_json() { let mut app = init_service(App::new().service(web::resource("/people").route( - web::post().to(|person: web::Json| async { + web::post().to(|person: web::Json| { HttpResponse::Ok().json(person.into_inner()) }), ))) @@ -1282,53 +1281,54 @@ mod tests { assert!(res.status().is_success()); } - /* + #[actix_rt::test] + async fn test_actor() { + use crate::Error; + use actix::prelude::*; - Comment out until actix decoupled of actix-http: - https://github.com/actix/actix/issues/321 + struct MyActor; - use futures::FutureExt; - - #[actix_rt::test] - async fn test_actor() { - use actix::Actor; - - struct MyActor; - - struct Num(usize); - impl actix::Message for Num { - type Result = usize; - } - impl actix::Actor for MyActor { - type Context = actix::Context; - } - impl actix::Handler for MyActor { - type Result = usize; - fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result { - msg.0 - } - } - - - let mut app = init_service(App::new().service(web::resource("/index.html").to( - move || { - addr.send(Num(1)).map(|res| match res { - Ok(res) => { - if res == 1 { - Ok(HttpResponse::Ok()) - } else { - Ok(HttpResponse::BadRequest()) - } - } - Err(err) => Err(err), - }) - }, - ))) - .await; - - let req = TestRequest::post().uri("/index.html").to_request(); - let res = app.call(req).await.unwrap(); - assert!(res.status().is_success()); + impl Actor for MyActor { + type Context = Context; } - */ + + struct Num(usize); + + impl Message for Num { + type Result = usize; + } + + impl Handler for MyActor { + type Result = usize; + + fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result { + msg.0 + } + } + + let addr = MyActor.start(); + + async fn actor_handler( + addr: Data>, + ) -> Result { + // `?` operator tests "actors" feature flag on actix-http + let res = addr.send(Num(1)).await?; + + if res == 1 { + Ok(HttpResponse::Ok()) + } else { + Ok(HttpResponse::BadRequest()) + } + } + + let srv = App::new() + .data(addr.clone()) + .service(web::resource("/").to(actor_handler)); + + let mut app = init_service(srv).await; + + let req = TestRequest::post().uri("/").to_request(); + let res = app.call(req).await.unwrap(); + assert!(res.status().is_success()); + } } diff --git a/test-server/CHANGES.md b/test-server/CHANGES.md index 71b906b9f..e71e9d0b8 100644 --- a/test-server/CHANGES.md +++ b/test-server/CHANGES.md @@ -1,10 +1,13 @@ # Changes ## Unreleased - 2020-xx-xx + + +## 2.0.0 - 2020-09-11 * Update actix-codec and actix-utils dependencies. -## [2.0.0-alpha.1] - 2020-05-23 +## 2.0.0-alpha.1 - 2020-05-23 * Update the `time` dependency to 0.2.7 * Update `actix-connect` dependency to 2.0.0-alpha.2 * Make `test_server` `async` fn. diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 8aecda401..d06bd5dec 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http-test" -version = "2.0.0-alpha.1" +version = "2.0.0" authors = ["Nikolay Kim "] description = "Actix HTTP test server" readme = "README.md" @@ -29,14 +29,14 @@ default = [] openssl = ["open-ssl", "awc/openssl"] [dependencies] -actix-service = "1.0.1" +actix-service = "1.0.6" actix-codec = "0.3.0" actix-connect = "2.0.0" actix-utils = "2.0.0" -actix-rt = "1.0.0" +actix-rt = "1.1.1" actix-server = "1.0.0" actix-testing = "1.0.0" -awc = "2.0.0-beta.4" +awc = "2.0.0" base64 = "0.12" bytes = "0.5.3" @@ -52,5 +52,5 @@ time = { version = "0.2.7", default-features = false, features = ["std"] } open-ssl = { version = "0.10", package = "openssl", optional = true } [dev-dependencies] -actix-web = "3.0.0-beta.4" -actix-http = "2.0.0-beta.4" +actix-web = "3.0.0" +actix-http = "2.0.0" diff --git a/test-server/src/lib.rs b/test-server/src/lib.rs index f6c1183b4..5d5750279 100644 --- a/test-server/src/lib.rs +++ b/test-server/src/lib.rs @@ -90,7 +90,7 @@ pub async fn test_server>(factory: F) -> TestServer } }; - Client::build().connector(connector).finish() + Client::builder().connector(connector).finish() }; actix_connect::start_default_resolver().await.unwrap(); diff --git a/tests/test_httpserver.rs b/tests/test_httpserver.rs index 50c0a7649..118640aca 100644 --- a/tests/test_httpserver.rs +++ b/tests/test_httpserver.rs @@ -43,7 +43,7 @@ async fn test_start() { { use actix_http::client; - let client = awc::Client::build() + let client = awc::Client::builder() .connector( client::Connector::new() .timeout(Duration::from_millis(100)) @@ -115,7 +115,7 @@ async fn test_start_ssl() { .set_alpn_protos(b"\x02h2\x08http/1.1") .map_err(|e| log::error!("Can not set alpn protocol: {:?}", e)); - let client = awc::Client::build() + let client = awc::Client::builder() .connector( awc::Connector::new() .ssl(builder.build())