1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

update actix-service dep

This commit is contained in:
Nikolay Kim 2019-12-08 19:25:24 +06:00
parent 4a8a9ef405
commit 1f3ffe38e8
8 changed files with 27 additions and 24 deletions

View File

@ -127,3 +127,6 @@ actix-session = { path = "actix-session" }
actix-files = { path = "actix-files" } actix-files = { path = "actix-files" }
actix-multipart = { path = "actix-multipart" } actix-multipart = { path = "actix-multipart" }
awc = { path = "awc" } awc = { path = "awc" }
actix-service = { git = "https://github.com/actix/actix-net.git" }
actix-server = { git = "https://github.com/actix/actix-net.git" }

View File

@ -822,7 +822,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use actix_service::{service_fn2, Transform}; use actix_service::{fn_service, Transform};
use actix_web::test::{self, TestRequest}; use actix_web::test::{self, TestRequest};
use super::*; use super::*;
@ -1083,7 +1083,7 @@ mod tests {
.expose_headers(exposed_headers.clone()) .expose_headers(exposed_headers.clone())
.allowed_header(header::CONTENT_TYPE) .allowed_header(header::CONTENT_TYPE)
.finish() .finish()
.new_transform(service_fn2(|req: ServiceRequest| { .new_transform(fn_service(|req: ServiceRequest| {
ok(req.into_response( ok(req.into_response(
HttpResponse::Ok().header(header::VARY, "Accept").finish(), HttpResponse::Ok().header(header::VARY, "Accept").finish(),
)) ))

View File

@ -8,7 +8,7 @@ use std::{io, net, rc};
use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_codec::{AsyncRead, AsyncWrite, Framed};
use actix_rt::net::TcpStream; use actix_rt::net::TcpStream;
use actix_service::{ use actix_service::{
factory_fn, pipeline_factory, service_fn2, IntoServiceFactory, Service, fn_factory, fn_service, pipeline_factory, IntoServiceFactory, Service,
ServiceFactory, ServiceFactory,
}; };
use bytes::Bytes; use bytes::Bytes;
@ -87,9 +87,9 @@ where
Error = DispatchError, Error = DispatchError,
InitError = S::InitError, InitError = S::InitError,
> { > {
pipeline_factory(factory_fn(|| { pipeline_factory(fn_factory(|| {
async { async {
Ok::<_, S::InitError>(service_fn2(|io: TcpStream| { Ok::<_, S::InitError>(fn_service(|io: TcpStream| {
let peer_addr = io.peer_addr().ok(); let peer_addr = io.peer_addr().ok();
ok::<_, DispatchError>((io, peer_addr)) ok::<_, DispatchError>((io, peer_addr))
})) }))
@ -101,7 +101,7 @@ where
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
mod 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::{Acceptor, SslAcceptor, SslStream};
use actix_tls::{openssl::HandshakeError, SslError}; use actix_tls::{openssl::HandshakeError, SslError};
@ -131,8 +131,8 @@ mod openssl {
.map_err(SslError::Ssl) .map_err(SslError::Ssl)
.map_init_err(|_| panic!()), .map_init_err(|_| panic!()),
) )
.and_then(factory_fn(|| { .and_then(fn_factory(|| {
ok::<_, S::InitError>(service_fn2(|io: SslStream<TcpStream>| { ok::<_, S::InitError>(fn_service(|io: SslStream<TcpStream>| {
let peer_addr = io.get_ref().peer_addr().ok(); let peer_addr = io.get_ref().peer_addr().ok();
ok((io, peer_addr)) ok((io, peer_addr))
})) }))
@ -176,8 +176,8 @@ mod rustls {
.map_err(SslError::Ssl) .map_err(SslError::Ssl)
.map_init_err(|_| panic!()), .map_init_err(|_| panic!()),
) )
.and_then(factory_fn(|| { .and_then(fn_factory(|| {
ok::<_, S::InitError>(service_fn2(|io: TlsStream<TcpStream>| { ok::<_, S::InitError>(fn_service(|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().0.peer_addr().ok(); let peer_addr = io.get_ref().0.peer_addr().ok();
ok((io, peer_addr)) ok((io, peer_addr))
})) }))

View File

@ -2,7 +2,7 @@
use std::io; use std::io;
use actix_http_test::TestServer; use actix_http_test::TestServer;
use actix_service::{service_fn, ServiceFactory}; use actix_service::{fn_service, ServiceFactory};
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use futures::future::{err, ok, ready}; 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() { async fn test_h2_response_http_error_handling() {
let mut srv = TestServer::start(move || { let mut srv = TestServer::start(move || {
HttpService::build() HttpService::build()
.h2(service_fn(|_| { .h2(fn_service(|_| {
let broken_header = Bytes::from_static(b"\0\0\0"); let broken_header = Bytes::from_static(b"\0\0\0");
ok::<_, ()>( ok::<_, ()>(
Response::Ok() Response::Ok()

View File

@ -4,7 +4,7 @@ use actix_http::http::header::{self, HeaderName, HeaderValue};
use actix_http::http::{Method, StatusCode, Version}; use actix_http::http::{Method, StatusCode, Version};
use actix_http::{body, error, Error, HttpService, Request, Response}; use actix_http::{body, error, Error, HttpService, Request, Response};
use actix_http_test::TestServer; 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 bytes::{Bytes, BytesMut};
use futures::future::{self, err, ok}; 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() { async fn test_h2_response_http_error_handling() {
let mut srv = TestServer::start(move || { let mut srv = TestServer::start(move || {
HttpService::build() HttpService::build()
.h2(factory_fn_cfg(|_: ()| { .h2(fn_factory_with_config(|_: ()| {
ok::<_, ()>(service_fn2(|_| { ok::<_, ()>(fn_service(|_| {
let broken_header = Bytes::from_static(b"\0\0\0"); let broken_header = Bytes::from_static(b"\0\0\0");
ok::<_, ()>( ok::<_, ()>(
Response::Ok() Response::Ok()

View File

@ -4,7 +4,7 @@ use std::{net, thread};
use actix_http_test::TestServer; use actix_http_test::TestServer;
use actix_rt::time::delay_for; use actix_rt::time::delay_for;
use actix_service::service_fn; use actix_service::fn_service;
use bytes::Bytes; use bytes::Bytes;
use futures::future::{self, err, ok, ready, FutureExt}; use futures::future::{self, err, ok, ready, FutureExt};
use futures::stream::{once, StreamExt}; use futures::stream::{once, StreamExt};
@ -56,7 +56,7 @@ async fn test_h1_2() {
async fn test_expect_continue() { async fn test_expect_continue() {
let srv = TestServer::start(|| { let srv = TestServer::start(|| {
HttpService::build() HttpService::build()
.expect(service_fn(|req: Request| { .expect(fn_service(|req: Request| {
if req.head().uri.query() == Some("yes=") { if req.head().uri.query() == Some("yes=") {
ok(req) ok(req)
} else { } else {
@ -84,7 +84,7 @@ async fn test_expect_continue() {
async fn test_expect_continue_h1() { async fn test_expect_continue_h1() {
let srv = TestServer::start(|| { let srv = TestServer::start(|| {
HttpService::build() HttpService::build()
.expect(service_fn(|req: Request| { .expect(fn_service(|req: Request| {
delay_for(Duration::from_millis(20)).then(move |_| { delay_for(Duration::from_millis(20)).then(move |_| {
if req.head().uri.query() == Some("yes=") { if req.head().uri.query() == Some("yes=") {
ok(req) 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() .tcp()
}); });
@ -117,7 +117,7 @@ async fn test_chunked_payload() {
let srv = TestServer::start(|| { let srv = TestServer::start(|| {
HttpService::build() HttpService::build()
.h1(service_fn(|mut request: Request| { .h1(fn_service(|mut request: Request| {
request request
.take_payload() .take_payload()
.map(|res| match res { .map(|res| match res {
@ -602,7 +602,7 @@ async fn test_h1_body_chunked_implicit() {
async fn test_h1_response_http_error_handling() { async fn test_h1_response_http_error_handling() {
let mut srv = TestServer::start(|| { let mut srv = TestServer::start(|| {
HttpService::build() HttpService::build()
.h1(service_fn(|_| { .h1(fn_service(|_| {
let broken_header = Bytes::from_static(b"\0\0\0"); let broken_header = Bytes::from_static(b"\0\0\0");
ok::<_, ()>( ok::<_, ()>(
Response::Ok() Response::Ok()

View File

@ -38,7 +38,7 @@ async fn service(msg: ws::Frame) -> Result<ws::Message, Error> {
async fn test_simple() { async fn test_simple() {
let mut srv = TestServer::start(|| { let mut srv = TestServer::start(|| {
HttpService::build() HttpService::build()
.upgrade(actix_service::service_fn(ws_service)) .upgrade(actix_service::fn_service(ws_service))
.finish(|_| future::ok::<_, ()>(Response::NotFound())) .finish(|_| future::ok::<_, ()>(Response::NotFound()))
.tcp() .tcp()
}); });

View File

@ -8,7 +8,7 @@ use std::task::{Context, Poll};
use actix_http::{Extensions, Request, Response}; use actix_http::{Extensions, Request, Response};
use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url}; use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url};
use actix_service::boxed::{self, BoxService, BoxServiceFactory}; 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 futures::future::{ok, FutureExt, LocalBoxFuture};
use crate::config::{AppConfig, AppService}; use crate::config::{AppConfig, AppService};
@ -69,7 +69,7 @@ where
fn new_service(&self, _: ()) -> Self::Future { fn new_service(&self, _: ()) -> Self::Future {
// update resource default service // update resource default service
let default = self.default.clone().unwrap_or_else(|| { 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())) ok(req.into_response(Response::NotFound().finish()))
}))) })))
}); });