diff --git a/Cargo.toml b/Cargo.toml index 1674502d8..d848861ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,3 +127,6 @@ actix-session = { path = "actix-session" } actix-files = { path = "actix-files" } actix-multipart = { path = "actix-multipart" } awc = { path = "awc" } + +actix-service = { git = "https://github.com/actix/actix-net.git" } +actix-server = { git = "https://github.com/actix/actix-net.git" } \ No newline at end of file diff --git a/actix-cors/src/lib.rs b/actix-cors/src/lib.rs index 71d98f896..ddb20d2b5 100644 --- a/actix-cors/src/lib.rs +++ b/actix-cors/src/lib.rs @@ -822,7 +822,7 @@ where #[cfg(test)] mod tests { - use actix_service::{service_fn2, Transform}; + use actix_service::{fn_service, Transform}; use actix_web::test::{self, TestRequest}; use super::*; @@ -1083,7 +1083,7 @@ mod tests { .expose_headers(exposed_headers.clone()) .allowed_header(header::CONTENT_TYPE) .finish() - .new_transform(service_fn2(|req: ServiceRequest| { + .new_transform(fn_service(|req: ServiceRequest| { ok(req.into_response( HttpResponse::Ok().header(header::VARY, "Accept").finish(), )) diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index cdef71c57..da2499345 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -8,7 +8,7 @@ use std::{io, net, rc}; use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_rt::net::TcpStream; use actix_service::{ - factory_fn, pipeline_factory, service_fn2, IntoServiceFactory, Service, + fn_factory, fn_service, pipeline_factory, IntoServiceFactory, Service, ServiceFactory, }; use bytes::Bytes; @@ -87,9 +87,9 @@ where Error = DispatchError, InitError = S::InitError, > { - pipeline_factory(factory_fn(|| { + pipeline_factory(fn_factory(|| { async { - Ok::<_, S::InitError>(service_fn2(|io: TcpStream| { + Ok::<_, S::InitError>(fn_service(|io: TcpStream| { let peer_addr = io.peer_addr().ok(); ok::<_, DispatchError>((io, peer_addr)) })) @@ -101,7 +101,7 @@ where #[cfg(feature = "openssl")] mod openssl { - use actix_service::{factory_fn, service_fn2}; + use actix_service::{fn_factory, fn_service}; use actix_tls::openssl::{Acceptor, SslAcceptor, SslStream}; use actix_tls::{openssl::HandshakeError, SslError}; @@ -131,8 +131,8 @@ mod openssl { .map_err(SslError::Ssl) .map_init_err(|_| panic!()), ) - .and_then(factory_fn(|| { - ok::<_, S::InitError>(service_fn2(|io: SslStream| { + .and_then(fn_factory(|| { + ok::<_, S::InitError>(fn_service(|io: SslStream| { let peer_addr = io.get_ref().peer_addr().ok(); ok((io, peer_addr)) })) @@ -176,8 +176,8 @@ mod rustls { .map_err(SslError::Ssl) .map_init_err(|_| panic!()), ) - .and_then(factory_fn(|| { - ok::<_, S::InitError>(service_fn2(|io: TlsStream| { + .and_then(fn_factory(|| { + ok::<_, S::InitError>(fn_service(|io: TlsStream| { let peer_addr = io.get_ref().0.peer_addr().ok(); ok((io, peer_addr)) })) diff --git a/actix-http/tests/test_openssl.rs b/actix-http/tests/test_openssl.rs index 35e234af9..5d466ee30 100644 --- a/actix-http/tests/test_openssl.rs +++ b/actix-http/tests/test_openssl.rs @@ -2,7 +2,7 @@ use std::io; use actix_http_test::TestServer; -use actix_service::{service_fn, ServiceFactory}; +use actix_service::{fn_service, ServiceFactory}; use bytes::{Bytes, BytesMut}; use futures::future::{err, ok, ready}; @@ -361,7 +361,7 @@ async fn test_h2_body_chunked_explicit() { async fn test_h2_response_http_error_handling() { let mut srv = TestServer::start(move || { HttpService::build() - .h2(service_fn(|_| { + .h2(fn_service(|_| { let broken_header = Bytes::from_static(b"\0\0\0"); ok::<_, ()>( Response::Ok() diff --git a/actix-http/tests/test_rustls.rs b/actix-http/tests/test_rustls.rs index 89719221d..b5c5cf3b1 100644 --- a/actix-http/tests/test_rustls.rs +++ b/actix-http/tests/test_rustls.rs @@ -4,7 +4,7 @@ use actix_http::http::header::{self, HeaderName, HeaderValue}; use actix_http::http::{Method, StatusCode, Version}; use actix_http::{body, error, Error, HttpService, Request, Response}; use actix_http_test::TestServer; -use actix_service::{factory_fn_cfg, service_fn2}; +use actix_service::{fn_factory_with_config, fn_service}; use bytes::{Bytes, BytesMut}; use futures::future::{self, err, ok}; @@ -367,8 +367,8 @@ async fn test_h2_body_chunked_explicit() { async fn test_h2_response_http_error_handling() { let mut srv = TestServer::start(move || { HttpService::build() - .h2(factory_fn_cfg(|_: ()| { - ok::<_, ()>(service_fn2(|_| { + .h2(fn_factory_with_config(|_: ()| { + ok::<_, ()>(fn_service(|_| { let broken_header = Bytes::from_static(b"\0\0\0"); ok::<_, ()>( Response::Ok() diff --git a/actix-http/tests/test_server.rs b/actix-http/tests/test_server.rs index 850d30a3f..fc51a103d 100644 --- a/actix-http/tests/test_server.rs +++ b/actix-http/tests/test_server.rs @@ -4,7 +4,7 @@ use std::{net, thread}; use actix_http_test::TestServer; use actix_rt::time::delay_for; -use actix_service::service_fn; +use actix_service::fn_service; use bytes::Bytes; use futures::future::{self, err, ok, ready, FutureExt}; use futures::stream::{once, StreamExt}; @@ -56,7 +56,7 @@ async fn test_h1_2() { async fn test_expect_continue() { let srv = TestServer::start(|| { HttpService::build() - .expect(service_fn(|req: Request| { + .expect(fn_service(|req: Request| { if req.head().uri.query() == Some("yes=") { ok(req) } else { @@ -84,7 +84,7 @@ async fn test_expect_continue() { async fn test_expect_continue_h1() { let srv = TestServer::start(|| { HttpService::build() - .expect(service_fn(|req: Request| { + .expect(fn_service(|req: Request| { delay_for(Duration::from_millis(20)).then(move |_| { if req.head().uri.query() == Some("yes=") { ok(req) @@ -93,7 +93,7 @@ async fn test_expect_continue_h1() { } }) })) - .h1(service_fn(|_| future::ok::<_, ()>(Response::Ok().finish()))) + .h1(fn_service(|_| future::ok::<_, ()>(Response::Ok().finish()))) .tcp() }); @@ -117,7 +117,7 @@ async fn test_chunked_payload() { let srv = TestServer::start(|| { HttpService::build() - .h1(service_fn(|mut request: Request| { + .h1(fn_service(|mut request: Request| { request .take_payload() .map(|res| match res { @@ -602,7 +602,7 @@ async fn test_h1_body_chunked_implicit() { async fn test_h1_response_http_error_handling() { let mut srv = TestServer::start(|| { HttpService::build() - .h1(service_fn(|_| { + .h1(fn_service(|_| { let broken_header = Bytes::from_static(b"\0\0\0"); ok::<_, ()>( Response::Ok() diff --git a/actix-http/tests/test_ws.rs b/actix-http/tests/test_ws.rs index 284a4218a..f0e0ff63c 100644 --- a/actix-http/tests/test_ws.rs +++ b/actix-http/tests/test_ws.rs @@ -38,7 +38,7 @@ async fn service(msg: ws::Frame) -> Result { async fn test_simple() { let mut srv = TestServer::start(|| { HttpService::build() - .upgrade(actix_service::service_fn(ws_service)) + .upgrade(actix_service::fn_service(ws_service)) .finish(|_| future::ok::<_, ()>(Response::NotFound())) .tcp() }); diff --git a/src/app_service.rs b/src/app_service.rs index b6e4388a1..bb42a3dd9 100644 --- a/src/app_service.rs +++ b/src/app_service.rs @@ -8,7 +8,7 @@ use std::task::{Context, Poll}; use actix_http::{Extensions, Request, Response}; use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url}; use actix_service::boxed::{self, BoxService, BoxServiceFactory}; -use actix_service::{service_fn, Service, ServiceFactory}; +use actix_service::{fn_service, Service, ServiceFactory}; use futures::future::{ok, FutureExt, LocalBoxFuture}; use crate::config::{AppConfig, AppService}; @@ -69,7 +69,7 @@ where fn new_service(&self, _: ()) -> Self::Future { // update resource default service let default = self.default.clone().unwrap_or_else(|| { - Rc::new(boxed::factory(service_fn(|req: ServiceRequest| { + Rc::new(boxed::factory(fn_service(|req: ServiceRequest| { ok(req.into_response(Response::NotFound().finish())) }))) });