mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
use generic HttpService
This commit is contained in:
parent
60c048c8cd
commit
6e638129c5
@ -2,7 +2,9 @@ use std::marker::PhantomData;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{fmt, io, net};
|
use std::{fmt, io, net};
|
||||||
|
|
||||||
use actix_http::{body::MessageBody, h1, KeepAlive, Request, Response, ServiceConfig};
|
use actix_http::{
|
||||||
|
body::MessageBody, HttpService, KeepAlive, Request, Response, ServiceConfig,
|
||||||
|
};
|
||||||
use actix_rt::System;
|
use actix_rt::System;
|
||||||
use actix_server::{Server, ServerBuilder};
|
use actix_server::{Server, ServerBuilder};
|
||||||
use actix_service::{IntoNewService, NewService};
|
use actix_service::{IntoNewService, NewService};
|
||||||
@ -72,10 +74,10 @@ where
|
|||||||
F: Fn() -> I + Send + Clone + 'static,
|
F: Fn() -> I + Send + Clone + 'static,
|
||||||
I: IntoNewService<S, Request>,
|
I: IntoNewService<S, Request>,
|
||||||
S: NewService<Request>,
|
S: NewService<Request>,
|
||||||
S::Error: fmt::Debug,
|
S::Error: fmt::Debug + 'static,
|
||||||
S::Response: Into<Response<B>>,
|
S::Response: Into<Response<B>>,
|
||||||
S::Service: 'static,
|
S::Service: 'static,
|
||||||
B: MessageBody,
|
B: MessageBody + 'static,
|
||||||
{
|
{
|
||||||
/// Create new http server with application factory
|
/// Create new http server with application factory
|
||||||
pub fn new(factory: F) -> Self {
|
pub fn new(factory: F) -> Self {
|
||||||
@ -244,7 +246,7 @@ where
|
|||||||
let c = cfg.lock();
|
let c = cfg.lock();
|
||||||
let service_config =
|
let service_config =
|
||||||
ServiceConfig::new(c.keep_alive, c.client_timeout, 0);
|
ServiceConfig::new(c.keep_alive, c.client_timeout, 0);
|
||||||
h1::H1Service::with_config(service_config, factory())
|
HttpService::with_config(service_config, factory())
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -298,7 +300,7 @@ where
|
|||||||
let service_config =
|
let service_config =
|
||||||
ServiceConfig::new(c.keep_alive, c.client_timeout, c.client_timeout);
|
ServiceConfig::new(c.keep_alive, c.client_timeout, c.client_timeout);
|
||||||
acceptor.clone().map_err(|e| SslError::Ssl(e)).and_then(
|
acceptor.clone().map_err(|e| SslError::Ssl(e)).and_then(
|
||||||
h1::H1Service::with_config(service_config, factory())
|
HttpService::with_config(service_config, factory())
|
||||||
.map_err(|e| SslError::Service(e))
|
.map_err(|e| SslError::Service(e))
|
||||||
.map_init_err(|_| ()),
|
.map_init_err(|_| ()),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user