From 6a0cd2dced8b085865e966e2d40baf1b8ad9d640 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 22 Dec 2019 17:12:22 +0400 Subject: [PATCH] Rename HttpServer::start() to HttpServer::run() --- CHANGES.md | 7 +++++++ Cargo.toml | 2 +- MIGRATION.md | 3 +++ actix-session/src/lib.rs | 2 +- awc/tests/test_client.rs | 2 +- awc/tests/test_rustls_client.rs | 2 +- awc/tests/test_ssl_client.rs | 2 +- examples/basic.rs | 2 +- examples/uds.rs | 2 +- src/lib.rs | 2 +- src/server.rs | 18 +++++++----------- tests/test_httpserver.rs | 4 ++-- 12 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 66b214bdc..0291f75ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [2.0.0] - 2019-12-xx + +### Changed + +* Rename `HttpServer::start()` to `HttpServer::run()` + + ## [2.0.0-rc] - 2019-12-20 ### Changed diff --git a/Cargo.toml b/Cargo.toml index 28720beb5..7ffaab75b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "2.0.0-rc" +version = "2.0.0" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" diff --git a/MIGRATION.md b/MIGRATION.md index 357a4e4ca..0ced4493d 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,5 +1,8 @@ ## 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`. Stored data is available via `HttpRequest::app_data()` method at runtime. diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index ac60901c3..b6e5dd331 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -37,7 +37,7 @@ //! ) //! .service(web::resource("/").to(|| HttpResponse::Ok()))) //! .bind("127.0.0.1:59880")? -//! .start() +//! .run() //! .await //! } //! ``` diff --git a/awc/tests/test_client.rs b/awc/tests/test_client.rs index 69e40ad25..8fb04b005 100644 --- a/awc/tests/test_client.rs +++ b/awc/tests/test_client.rs @@ -14,7 +14,7 @@ use rand::Rng; use actix_http::HttpService; 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::http::Cookie; use actix_web::middleware::Compress; diff --git a/awc/tests/test_rustls_client.rs b/awc/tests/test_rustls_client.rs index 5170555f0..1d7eb7bc5 100644 --- a/awc/tests/test_rustls_client.rs +++ b/awc/tests/test_rustls_client.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use actix_http::HttpService; 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::{dev::AppConfig, web, App, HttpResponse}; use futures::future::ok; diff --git a/awc/tests/test_ssl_client.rs b/awc/tests/test_ssl_client.rs index 94a061acf..d3995b4be 100644 --- a/awc/tests/test_ssl_client.rs +++ b/awc/tests/test_ssl_client.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use actix_http::HttpService; 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::{dev::AppConfig, web, App, HttpResponse}; use futures::future::ok; diff --git a/examples/basic.rs b/examples/basic.rs index b5b69fce2..bd6f8146f 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -42,6 +42,6 @@ async fn main() -> std::io::Result<()> { }) .bind("127.0.0.1:8080")? .workers(1) - .start() + .run() .await } diff --git a/examples/uds.rs b/examples/uds.rs index 8db4cf230..77f245d99 100644 --- a/examples/uds.rs +++ b/examples/uds.rs @@ -45,7 +45,7 @@ async fn main() -> std::io::Result<()> { }) .bind_uds("/Users/fafhrd91/uds-test")? .workers(1) - .start() + .run() .await } diff --git a/src/lib.rs b/src/lib.rs index bc89c6450..b8d358d81 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ //! web::resource("/{name}/{id}/index.html").to(index)) //! ) //! .bind("127.0.0.1:8080")? -//! .start() +//! .run() //! .await //! } //! ``` diff --git a/src/server.rs b/src/server.rs index f460afe48..11cfbb6bc 100644 --- a/src/server.rs +++ b/src/server.rs @@ -38,21 +38,17 @@ struct Config { /// /// Create new http server with application factory. /// -/// ```rust -/// use std::io; +/// ```rust,no_run /// use actix_web::{web, App, HttpResponse, HttpServer}; /// -/// fn main() -> io::Result<()> { -/// let sys = actix_rt::System::new("example"); // <- create Actix runtime -/// +/// #[actix_rt::main] +/// async fn main() -> std::io::Result<()> { /// HttpServer::new( /// || App::new() /// .service(web::resource("/").to(|| HttpResponse::Ok()))) /// .bind("127.0.0.1:59090")? -/// .start(); -/// -/// # actix_rt::System::current().stop(); -/// sys.run() +/// .run() +/// .await /// } /// ``` pub struct HttpServer @@ -557,11 +553,11 @@ where /// async fn main() -> io::Result<()> { /// HttpServer::new(|| App::new().service(web::resource("/").to(|| HttpResponse::Ok()))) /// .bind("127.0.0.1:0")? - /// .start() + /// .run() /// .await /// } /// ``` - pub fn start(self) -> Server { + pub fn run(self) -> Server { self.builder.start() } } diff --git a/tests/test_httpserver.rs b/tests/test_httpserver.rs index 48d8b3872..ecd5c9ffb 100644 --- a/tests/test_httpserver.rs +++ b/tests/test_httpserver.rs @@ -42,7 +42,7 @@ async fn test_start() { .disable_signals() .bind(format!("{}", addr)) .unwrap() - .start(); + .run(); let _ = tx.send((srv, actix_rt::System::current())); let _ = sys.run(); @@ -111,7 +111,7 @@ async fn test_start_ssl() { .disable_signals() .bind_openssl(format!("{}", addr), builder) .unwrap() - .start(); + .run(); let _ = tx.send((srv, actix_rt::System::current())); let _ = sys.run();