rename HttpServices to HttpFlow

This commit is contained in:
fakeshadow 2021-01-06 19:46:02 +08:00
parent 12de0e96fc
commit 3a6c64fafd
5 changed files with 27 additions and 28 deletions

View File

@ -23,7 +23,7 @@ use crate::error::{DispatchError, Error};
use crate::error::{ParseError, PayloadError};
use crate::request::Request;
use crate::response::Response;
use crate::service::HttpServices;
use crate::service::HttpFlow;
use crate::OnConnectData;
use super::codec::Codec;
@ -91,7 +91,7 @@ where
U: Service<(Request, Framed<T, Codec>), Response = ()>,
U::Error: fmt::Display,
{
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
on_connect_data: OnConnectData,
flags: Flags,
peer_addr: Option<net::SocketAddr>,
@ -177,7 +177,7 @@ where
pub(crate) fn new(
stream: T,
config: ServiceConfig,
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
on_connect_data: OnConnectData,
peer_addr: Option<net::SocketAddr>,
) -> Self {
@ -200,7 +200,7 @@ where
config: ServiceConfig,
read_buf: BytesMut,
timeout: Option<Sleep>,
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
on_connect_data: OnConnectData,
peer_addr: Option<net::SocketAddr>,
) -> Self {
@ -561,7 +561,7 @@ where
req.head_mut().peer_addr = *this.peer_addr;
// merge on_connect_ext data into request extensions
this.on_connect_data.merge(&mut req);
this.on_connect_data.merge_into(&mut req);
if pl == MessageType::Stream
&& this.services.borrow().upgrade.is_some()
@ -1028,7 +1028,7 @@ mod tests {
lazy(|cx| {
let buf = TestBuffer::new("GET /test HTTP/1\r\n\r\n");
let services = HttpServices::new(ok_service(), ExpectHandler, None);
let services = HttpFlow::new(ok_service(), ExpectHandler, None);
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf,
@ -1068,7 +1068,7 @@ mod tests {
let cfg = ServiceConfig::new(KeepAlive::Disabled, 1, 1, false, None);
let services = HttpServices::new(echo_path_service(), ExpectHandler, None);
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf,
@ -1122,7 +1122,7 @@ mod tests {
let cfg = ServiceConfig::new(KeepAlive::Disabled, 1, 1, false, None);
let services = HttpServices::new(echo_path_service(), ExpectHandler, None);
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf,
@ -1172,8 +1172,7 @@ mod tests {
let mut buf = TestSeqBuffer::empty();
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
let services =
HttpServices::new(echo_payload_service(), ExpectHandler, None);
let services = HttpFlow::new(echo_payload_service(), ExpectHandler, None);
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf.clone(),
@ -1245,7 +1244,7 @@ mod tests {
let mut buf = TestSeqBuffer::empty();
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
let services = HttpServices::new(echo_path_service(), ExpectHandler, None);
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf.clone(),
@ -1306,7 +1305,7 @@ mod tests {
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
let services =
HttpServices::new(ok_service(), ExpectHandler, Some(UpgradeHandler));
HttpFlow::new(ok_service(), ExpectHandler, Some(UpgradeHandler));
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf.clone(),

View File

@ -17,7 +17,7 @@ use crate::config::ServiceConfig;
use crate::error::{DispatchError, Error};
use crate::request::Request;
use crate::response::Response;
use crate::service::HttpServices;
use crate::service::HttpFlow;
use crate::{ConnectCallback, OnConnectData};
use super::codec::Codec;
@ -367,7 +367,7 @@ where
X: Service<Request>,
U: Service<(Request, Framed<T, Codec>)>,
{
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
cfg: ServiceConfig,
_phantom: PhantomData<B>,
@ -392,7 +392,7 @@ where
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
) -> H1ServiceHandler<T, S, B, X, U> {
H1ServiceHandler {
services: HttpServices::new(service, expect, upgrade),
services: HttpFlow::new(service, expect, upgrade),
cfg,
on_connect_ext,
_phantom: PhantomData,

View File

@ -24,7 +24,7 @@ use crate::message::ResponseHead;
use crate::payload::Payload;
use crate::request::Request;
use crate::response::Response;
use crate::service::HttpServices;
use crate::service::HttpFlow;
use crate::OnConnectData;
const CHUNK_SIZE: usize = 16_384;
@ -37,7 +37,7 @@ where
S: Service<Request>,
B: MessageBody,
{
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
connection: Connection<T, Bytes>,
on_connect_data: OnConnectData,
config: ServiceConfig,
@ -56,7 +56,7 @@ where
B: MessageBody,
{
pub(crate) fn new(
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
connection: Connection<T, Bytes>,
on_connect_data: OnConnectData,
config: ServiceConfig,
@ -134,7 +134,7 @@ where
head.peer_addr = this.peer_addr;
// merge on_connect_ext data into request extensions
this.on_connect_data.merge(&mut req);
this.on_connect_data.merge_into(&mut req);
let svc = ServiceResponse::<S::Future, S::Response, S::Error, B> {
state: ServiceResponseState::ServiceCall(

View File

@ -22,7 +22,7 @@ use crate::config::ServiceConfig;
use crate::error::{DispatchError, Error};
use crate::request::Request;
use crate::response::Response;
use crate::service::HttpServices;
use crate::service::HttpFlow;
use crate::{ConnectCallback, OnConnectData};
use super::dispatcher::Dispatcher;
@ -249,7 +249,7 @@ pub struct H2ServiceHandler<T, S, B>
where
S: Service<Request>,
{
services: Rc<RefCell<HttpServices<S, (), ()>>>,
services: Rc<RefCell<HttpFlow<S, (), ()>>>,
cfg: ServiceConfig,
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
_phantom: PhantomData<B>,
@ -269,7 +269,7 @@ where
service: S,
) -> H2ServiceHandler<T, S, B> {
H2ServiceHandler {
services: HttpServices::new(service, (), None),
services: HttpFlow::new(service, (), None),
cfg,
on_connect_ext,
_phantom: PhantomData,
@ -325,7 +325,7 @@ where
{
Incoming(Dispatcher<T, S, B, (), ()>),
Handshake(
Option<Rc<RefCell<HttpServices<S, (), ()>>>>,
Option<Rc<RefCell<HttpFlow<S, (), ()>>>>,
Option<ServiceConfig>,
Option<net::SocketAddr>,
OnConnectData,

View File

@ -441,20 +441,20 @@ where
X: Service<Request>,
U: Service<(Request, Framed<T, h1::Codec>)>,
{
services: Rc<RefCell<HttpServices<S, X, U>>>,
services: Rc<RefCell<HttpFlow<S, X, U>>>,
cfg: ServiceConfig,
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
_phantom: PhantomData<B>,
}
// a collection of service for http.
pub(super) struct HttpServices<S, X, U> {
pub(super) struct HttpFlow<S, X, U> {
pub(super) service: S,
pub(super) expect: X,
pub(super) upgrade: Option<U>,
}
impl<S, X, U> HttpServices<S, X, U> {
impl<S, X, U> HttpFlow<S, X, U> {
pub(super) fn new(service: S, expect: X, upgrade: Option<U>) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Self {
service,
@ -486,7 +486,7 @@ where
HttpServiceHandler {
cfg,
on_connect_ext,
services: HttpServices::new(service, expect, upgrade),
services: HttpFlow::new(service, expect, upgrade),
_phantom: PhantomData,
}
}
@ -603,7 +603,7 @@ where
Option<(
Handshake<T, Bytes>,
ServiceConfig,
Rc<RefCell<HttpServices<S, X, U>>>,
Rc<RefCell<HttpFlow<S, X, U>>>,
OnConnectData,
Option<net::SocketAddr>,
)>,