mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 15:51:06 +01:00
update actix-service dep
This commit is contained in:
parent
4a8a9ef405
commit
1f3ffe38e8
@ -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" }
|
@ -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(),
|
||||
))
|
||||
|
@ -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<TcpStream>| {
|
||||
.and_then(fn_factory(|| {
|
||||
ok::<_, S::InitError>(fn_service(|io: SslStream<TcpStream>| {
|
||||
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<TcpStream>| {
|
||||
.and_then(fn_factory(|| {
|
||||
ok::<_, S::InitError>(fn_service(|io: TlsStream<TcpStream>| {
|
||||
let peer_addr = io.get_ref().0.peer_addr().ok();
|
||||
ok((io, peer_addr))
|
||||
}))
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -38,7 +38,7 @@ async fn service(msg: ws::Frame) -> Result<ws::Message, Error> {
|
||||
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()
|
||||
});
|
||||
|
@ -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()))
|
||||
})))
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user