propagate new bound to web

This commit is contained in:
Rob Ede 2021-04-19 23:30:14 +01:00
parent 18ae545f9a
commit 080e1832cd
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
4 changed files with 14 additions and 10 deletions

View File

@ -1,6 +1,6 @@
use std::{env, io}; use std::{env, io};
use actix_http::{http::StatusCode, HttpService, Response}; use actix_http::{http::StatusCode, Error, HttpService, Response};
use actix_server::Server; use actix_server::Server;
use actix_utils::future; use actix_utils::future;
use http::header::HeaderValue; use http::header::HeaderValue;
@ -23,7 +23,7 @@ async fn main() -> io::Result<()> {
"x-head", "x-head",
HeaderValue::from_static("dummy value!"), HeaderValue::from_static("dummy value!"),
)); ));
future::ok::<_, ()>(res.body("Hello world!")) future::ok::<_, Error>(res.body("Hello world!"))
}) })
.tcp() .tcp()
})? })?

View File

@ -36,13 +36,14 @@ use std::{fmt, net, sync::mpsc, thread, time};
use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_codec::{AsyncRead, AsyncWrite, Framed};
pub use actix_http::test::TestBuffer; pub use actix_http::test::TestBuffer;
use actix_http::{ use actix_http::{
body::Body,
http::{HeaderMap, Method}, http::{HeaderMap, Method},
ws, HttpService, Request, Response, ws, HttpService, Request, Response,
}; };
use actix_service::{map_config, IntoServiceFactory, ServiceFactory}; use actix_service::{map_config, IntoServiceFactory, ServiceFactory};
use actix_web::{ use actix_web::{
dev::{AppConfig, MessageBody, Server, Service}, dev::{AppConfig, MessageBody, Server, Service},
rt, web, Error, rt, web,
}; };
use awc::{error::PayloadError, Client, ClientRequest, ClientResponse, Connector}; use awc::{error::PayloadError, Client, ClientRequest, ClientResponse, Connector};
use futures_core::Stream; use futures_core::Stream;
@ -81,7 +82,7 @@ where
F: Fn() -> I + Send + Clone + 'static, F: Fn() -> I + Send + Clone + 'static,
I: IntoServiceFactory<S, Request>, I: IntoServiceFactory<S, Request>,
S: ServiceFactory<Request, Config = AppConfig> + 'static, S: ServiceFactory<Request, Config = AppConfig> + 'static,
S::Error: Into<Error> + 'static, S::Error: Into<Response<Body>> + 'static,
S::InitError: fmt::Debug, S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static, S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static, <S::Service as Service<Request>>::Future: 'static,
@ -120,7 +121,7 @@ where
F: Fn() -> I + Send + Clone + 'static, F: Fn() -> I + Send + Clone + 'static,
I: IntoServiceFactory<S, Request>, I: IntoServiceFactory<S, Request>,
S: ServiceFactory<Request, Config = AppConfig> + 'static, S: ServiceFactory<Request, Config = AppConfig> + 'static,
S::Error: Into<Error> + 'static, S::Error: Into<Response<Body>> + 'static,
S::InitError: fmt::Debug, S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static, S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static, <S::Service as Service<Request>>::Future: 'static,

View File

@ -33,7 +33,9 @@ async fn test_simple() {
// start WebSocket service // start WebSocket service
let framed = framed.replace_codec(ws::Codec::new()); let framed = framed.replace_codec(ws::Codec::new());
ws::Dispatcher::with(framed, ws_service).await ws::Dispatcher::with(framed, ws_service)
.await
.map_err(Error::from)
} }
}) })
.finish(|_| ok::<_, Error>(Response::not_found())) .finish(|_| ok::<_, Error>(Response::not_found()))

View File

@ -7,7 +7,8 @@ use std::{
}; };
use actix_http::{ use actix_http::{
body::MessageBody, Error, Extensions, HttpService, KeepAlive, Request, Response, body::{Body, MessageBody},
Extensions, HttpService, KeepAlive, Request, Response,
}; };
use actix_server::{Server, ServerBuilder}; use actix_server::{Server, ServerBuilder};
use actix_service::{map_config, IntoServiceFactory, Service, ServiceFactory}; use actix_service::{map_config, IntoServiceFactory, Service, ServiceFactory};
@ -53,7 +54,7 @@ where
F: Fn() -> I + Send + Clone + 'static, F: Fn() -> I + Send + Clone + 'static,
I: IntoServiceFactory<S, Request>, I: IntoServiceFactory<S, Request>,
S: ServiceFactory<Request, Config = AppConfig>, S: ServiceFactory<Request, Config = AppConfig>,
S::Error: Into<Error>, S::Error: Into<Response<Body>>,
S::InitError: fmt::Debug, S::InitError: fmt::Debug,
S::Response: Into<Response<B>>, S::Response: Into<Response<B>>,
B: MessageBody, B: MessageBody,
@ -74,7 +75,7 @@ where
S: ServiceFactory<Request, Config = AppConfig> + 'static, S: ServiceFactory<Request, Config = AppConfig> + 'static,
// S::Future: 'static, // S::Future: 'static,
S::Error: Into<Error> + 'static, S::Error: Into<Response<Body>> + 'static,
S::InitError: fmt::Debug, S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static, S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static, <S::Service as Service<Request>>::Future: 'static,
@ -574,7 +575,7 @@ where
F: Fn() -> I + Send + Clone + 'static, F: Fn() -> I + Send + Clone + 'static,
I: IntoServiceFactory<S, Request>, I: IntoServiceFactory<S, Request>,
S: ServiceFactory<Request, Config = AppConfig>, S: ServiceFactory<Request, Config = AppConfig>,
S::Error: Into<Error>, S::Error: Into<Response<Body>>,
S::InitError: fmt::Debug, S::InitError: fmt::Debug,
S::Response: Into<Response<B>>, S::Response: Into<Response<B>>,
S::Service: 'static, S::Service: 'static,