mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 22:49:21 +02:00
update actix-net dependencies
This commit is contained in:
@ -4,7 +4,6 @@ use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
|
||||
use actix_http::body::{Body, MessageBody};
|
||||
use actix_server_config::ServerConfig;
|
||||
use actix_service::boxed::{self, BoxedNewService};
|
||||
use actix_service::{
|
||||
apply_transform, IntoNewService, IntoTransform, NewService, Transform,
|
||||
@ -59,6 +58,7 @@ impl<T, B> App<T, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
@ -234,6 +234,7 @@ where
|
||||
where
|
||||
F: IntoNewService<U>,
|
||||
U: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -319,6 +320,7 @@ where
|
||||
mw: F,
|
||||
) -> App<
|
||||
impl NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B1>,
|
||||
Error = Error,
|
||||
@ -384,6 +386,7 @@ where
|
||||
mw: F,
|
||||
) -> App<
|
||||
impl NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B1>,
|
||||
Error = Error,
|
||||
@ -400,10 +403,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> IntoNewService<AppInit<T, B>, ServerConfig> for App<T, B>
|
||||
impl<T, B> IntoNewService<AppInit<T, B>> for App<T, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
|
@ -6,7 +6,7 @@ use actix_http::{Extensions, Request, Response};
|
||||
use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url};
|
||||
use actix_server_config::ServerConfig;
|
||||
use actix_service::boxed::{self, BoxedNewService, BoxedService};
|
||||
use actix_service::{fn_service, NewService, Service};
|
||||
use actix_service::{service_fn, NewService, Service};
|
||||
use futures::future::{ok, Either, FutureResult};
|
||||
use futures::{Async, Future, Poll};
|
||||
|
||||
@ -31,6 +31,7 @@ type BoxedResponse = Either<
|
||||
pub struct AppInit<T, B>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
@ -46,15 +47,17 @@ where
|
||||
pub(crate) external: RefCell<Vec<ResourceDef>>,
|
||||
}
|
||||
|
||||
impl<T, B> NewService<ServerConfig> for AppInit<T, B>
|
||||
impl<T, B> NewService for AppInit<T, B>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
{
|
||||
type Config = ServerConfig;
|
||||
type Request = Request;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = T::Error;
|
||||
@ -65,7 +68,7 @@ where
|
||||
fn new_service(&self, cfg: &ServerConfig) -> Self::Future {
|
||||
// update resource default service
|
||||
let default = self.default.clone().unwrap_or_else(|| {
|
||||
Rc::new(boxed::new_service(fn_service(|req: ServiceRequest| {
|
||||
Rc::new(boxed::new_service(service_fn(|req: ServiceRequest| {
|
||||
Ok(req.into_response(Response::NotFound().finish()))
|
||||
})))
|
||||
});
|
||||
@ -148,6 +151,7 @@ where
|
||||
impl<T, B> Future for AppInitResult<T, B>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
@ -233,6 +237,7 @@ pub struct AppRoutingFactory {
|
||||
}
|
||||
|
||||
impl NewService for AppRoutingFactory {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
@ -391,6 +396,7 @@ impl AppEntry {
|
||||
}
|
||||
|
||||
impl NewService for AppEntry {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
|
@ -107,6 +107,7 @@ impl AppService {
|
||||
) where
|
||||
F: IntoNewService<S>,
|
||||
S: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
|
@ -1,7 +1,8 @@
|
||||
use std::convert::Infallible;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use actix_http::{Error, Payload, Response};
|
||||
use actix_service::{NewService, Service, Void};
|
||||
use actix_service::{NewService, Service};
|
||||
use futures::future::{ok, FutureResult};
|
||||
use futures::{try_ready, Async, Future, IntoFuture, Poll};
|
||||
|
||||
@ -71,7 +72,7 @@ where
|
||||
{
|
||||
type Request = (T, HttpRequest);
|
||||
type Response = ServiceResponse;
|
||||
type Error = Void;
|
||||
type Error = Infallible;
|
||||
type Future = HandlerServiceResponse<<R::Future as IntoFuture>::Future>;
|
||||
|
||||
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
||||
@ -98,7 +99,7 @@ where
|
||||
T::Error: Into<Error>,
|
||||
{
|
||||
type Item = ServiceResponse;
|
||||
type Error = Void;
|
||||
type Error = Infallible;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
match self.fut.poll() {
|
||||
@ -191,7 +192,7 @@ where
|
||||
{
|
||||
type Request = (T, HttpRequest);
|
||||
type Response = ServiceResponse;
|
||||
type Error = Void;
|
||||
type Error = Infallible;
|
||||
type Future = AsyncHandlerServiceResponse<R::Future>;
|
||||
|
||||
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
||||
@ -225,7 +226,7 @@ where
|
||||
T::Error: Into<Error>,
|
||||
{
|
||||
type Item = ServiceResponse;
|
||||
type Error = Void;
|
||||
type Error = Infallible;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
if let Some(ref mut fut) = self.fut2 {
|
||||
@ -280,9 +281,13 @@ impl<T: FromRequest, S> Extract<T, S> {
|
||||
|
||||
impl<T: FromRequest, S> NewService for Extract<T, S>
|
||||
where
|
||||
S: Service<Request = (T, HttpRequest), Response = ServiceResponse, Error = Void>
|
||||
+ Clone,
|
||||
S: Service<
|
||||
Request = (T, HttpRequest),
|
||||
Response = ServiceResponse,
|
||||
Error = Infallible,
|
||||
> + Clone,
|
||||
{
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = (Error, ServiceRequest);
|
||||
@ -305,8 +310,11 @@ pub struct ExtractService<T: FromRequest, S> {
|
||||
|
||||
impl<T: FromRequest, S> Service for ExtractService<T, S>
|
||||
where
|
||||
S: Service<Request = (T, HttpRequest), Response = ServiceResponse, Error = Void>
|
||||
+ Clone,
|
||||
S: Service<
|
||||
Request = (T, HttpRequest),
|
||||
Response = ServiceResponse,
|
||||
Error = Infallible,
|
||||
> + Clone,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
@ -339,7 +347,11 @@ pub struct ExtractResponse<T: FromRequest, S: Service> {
|
||||
|
||||
impl<T: FromRequest, S> Future for ExtractResponse<T, S>
|
||||
where
|
||||
S: Service<Request = (T, HttpRequest), Response = ServiceResponse, Error = Void>,
|
||||
S: Service<
|
||||
Request = (T, HttpRequest),
|
||||
Response = ServiceResponse,
|
||||
Error = Infallible,
|
||||
>,
|
||||
{
|
||||
type Item = ServiceResponse;
|
||||
type Error = (Error, ServiceRequest);
|
||||
|
@ -805,14 +805,15 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::{FnService, Transform};
|
||||
use actix_service::{IntoService, Transform};
|
||||
|
||||
use super::*;
|
||||
use crate::test::{self, block_on, TestRequest};
|
||||
|
||||
impl Cors {
|
||||
fn finish<S, B>(self, srv: S) -> CorsMiddleware<S>
|
||||
fn finish<F, S, B>(self, srv: F) -> CorsMiddleware<S>
|
||||
where
|
||||
F: IntoService<S>,
|
||||
S: Service<
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
@ -822,7 +823,8 @@ mod tests {
|
||||
B: 'static,
|
||||
{
|
||||
block_on(
|
||||
IntoTransform::<CorsFactory, S>::into_transform(self).new_transform(srv),
|
||||
IntoTransform::<CorsFactory, S>::into_transform(self)
|
||||
.new_transform(srv.into_service()),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
@ -1063,11 +1065,11 @@ mod tests {
|
||||
.allowed_headers(exposed_headers.clone())
|
||||
.expose_headers(exposed_headers.clone())
|
||||
.allowed_header(header::CONTENT_TYPE)
|
||||
.finish(FnService::new(move |req: ServiceRequest| {
|
||||
.finish(|req: ServiceRequest| {
|
||||
req.into_response(
|
||||
HttpResponse::Ok().header(header::VARY, "Accept").finish(),
|
||||
)
|
||||
}));
|
||||
});
|
||||
let req = TestRequest::with_header("Origin", "https://www.example.com")
|
||||
.method(Method::OPTIONS)
|
||||
.to_srv_request();
|
||||
|
@ -150,7 +150,7 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::FnService;
|
||||
use actix_service::IntoService;
|
||||
|
||||
use super::*;
|
||||
use crate::dev::ServiceRequest;
|
||||
@ -172,13 +172,13 @@ mod tests {
|
||||
assert_eq!(resp.headers().get(CONTENT_TYPE).unwrap(), "0001");
|
||||
|
||||
let req = TestRequest::default().to_srv_request();
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
let srv = |req: ServiceRequest| {
|
||||
req.into_response(HttpResponse::Ok().header(CONTENT_TYPE, "0002").finish())
|
||||
});
|
||||
};
|
||||
let mut mw = block_on(
|
||||
DefaultHeaders::new()
|
||||
.header(CONTENT_TYPE, "0001")
|
||||
.new_transform(srv),
|
||||
.new_transform(srv.into_service()),
|
||||
)
|
||||
.unwrap();
|
||||
let resp = block_on(mw.call(req)).unwrap();
|
||||
@ -187,11 +187,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_content_type() {
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
req.into_response(HttpResponse::Ok().finish())
|
||||
});
|
||||
let mut mw =
|
||||
block_on(DefaultHeaders::new().content_type().new_transform(srv)).unwrap();
|
||||
let srv = |req: ServiceRequest| req.into_response(HttpResponse::Ok().finish());
|
||||
let mut mw = block_on(
|
||||
DefaultHeaders::new()
|
||||
.content_type()
|
||||
.new_transform(srv.into_service()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let req = TestRequest::default().to_srv_request();
|
||||
let resp = block_on(mw.call(req)).unwrap();
|
||||
|
@ -142,7 +142,7 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::FnService;
|
||||
use actix_service::IntoService;
|
||||
use futures::future::ok;
|
||||
|
||||
use super::*;
|
||||
@ -159,14 +159,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_handler() {
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
let srv = |req: ServiceRequest| {
|
||||
req.into_response(HttpResponse::InternalServerError().finish())
|
||||
});
|
||||
};
|
||||
|
||||
let mut mw = test::block_on(
|
||||
ErrorHandlers::new()
|
||||
.handler(StatusCode::INTERNAL_SERVER_ERROR, render_500)
|
||||
.new_transform(srv),
|
||||
.new_transform(srv.into_service()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -185,14 +185,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_handler_async() {
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
let srv = |req: ServiceRequest| {
|
||||
req.into_response(HttpResponse::InternalServerError().finish())
|
||||
});
|
||||
};
|
||||
|
||||
let mut mw = test::block_on(
|
||||
ErrorHandlers::new()
|
||||
.handler(StatusCode::INTERNAL_SERVER_ERROR, render_500_async)
|
||||
.new_transform(srv),
|
||||
.new_transform(srv.into_service()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -457,7 +457,7 @@ impl<'a> fmt::Display for FormatDisplay<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::{FnService, Service, Transform};
|
||||
use actix_service::{IntoService, Service, Transform};
|
||||
|
||||
use super::*;
|
||||
use crate::http::{header, StatusCode};
|
||||
@ -465,16 +465,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_logger() {
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
let srv = |req: ServiceRequest| {
|
||||
req.into_response(
|
||||
HttpResponse::build(StatusCode::OK)
|
||||
.header("X-Test", "ttt")
|
||||
.finish(),
|
||||
)
|
||||
});
|
||||
};
|
||||
let logger = Logger::new("%% %{User-Agent}i %{X-Test}o %{HOME}e %D test");
|
||||
|
||||
let mut srv = block_on(logger.new_transform(srv)).unwrap();
|
||||
let mut srv = block_on(logger.new_transform(srv.into_service())).unwrap();
|
||||
|
||||
let req = TestRequest::with_header(
|
||||
header::USER_AGENT,
|
||||
|
@ -100,7 +100,7 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::FnService;
|
||||
use actix_service::IntoService;
|
||||
|
||||
use super::*;
|
||||
use crate::dev::ServiceRequest;
|
||||
@ -122,12 +122,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_in_place_normalization() {
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
let srv = |req: ServiceRequest| {
|
||||
assert_eq!("/v1/something/", req.path());
|
||||
req.into_response(HttpResponse::Ok().finish())
|
||||
});
|
||||
};
|
||||
|
||||
let mut normalize = block_on(NormalizePath.new_transform(srv)).unwrap();
|
||||
let mut normalize =
|
||||
block_on(NormalizePath.new_transform(srv.into_service())).unwrap();
|
||||
|
||||
let req = TestRequest::with_uri("/v1//something////").to_srv_request();
|
||||
let res = block_on(normalize.call(req)).unwrap();
|
||||
@ -138,12 +139,13 @@ mod tests {
|
||||
fn should_normalize_nothing() {
|
||||
const URI: &str = "/v1/something/";
|
||||
|
||||
let srv = FnService::new(|req: ServiceRequest| {
|
||||
let srv = |req: ServiceRequest| {
|
||||
assert_eq!(URI, req.path());
|
||||
req.into_response(HttpResponse::Ok().finish())
|
||||
});
|
||||
};
|
||||
|
||||
let mut normalize = block_on(NormalizePath.new_transform(srv)).unwrap();
|
||||
let mut normalize =
|
||||
block_on(NormalizePath.new_transform(srv.into_service())).unwrap();
|
||||
|
||||
let req = TestRequest::with_uri(URI).to_srv_request();
|
||||
let res = block_on(normalize.call(req)).unwrap();
|
||||
|
@ -75,6 +75,7 @@ impl Resource {
|
||||
impl<T> Resource<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -274,6 +275,7 @@ where
|
||||
mw: F,
|
||||
) -> Resource<
|
||||
impl NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -340,6 +342,7 @@ where
|
||||
mw: F,
|
||||
) -> Resource<
|
||||
impl NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -360,6 +363,7 @@ where
|
||||
where
|
||||
F: IntoNewService<U>,
|
||||
U: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -380,6 +384,7 @@ where
|
||||
impl<T> HttpServiceFactory for Resource<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -411,6 +416,7 @@ where
|
||||
impl<T> IntoNewService<T> for Resource<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -435,6 +441,7 @@ pub struct ResourceFactory {
|
||||
}
|
||||
|
||||
impl NewService for ResourceFactory {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
@ -575,6 +582,7 @@ impl ResourceEndpoint {
|
||||
}
|
||||
|
||||
impl NewService for ResourceEndpoint {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
|
@ -26,6 +26,7 @@ type BoxedRouteService<Req, Res> = Box<
|
||||
|
||||
type BoxedRouteNewService<Req, Res> = Box<
|
||||
NewService<
|
||||
Config = (),
|
||||
Request = Req,
|
||||
Response = Res,
|
||||
Error = Error,
|
||||
@ -61,6 +62,7 @@ impl Route {
|
||||
}
|
||||
|
||||
impl NewService for Route {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
@ -283,6 +285,7 @@ where
|
||||
impl<T> RouteNewService<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = (Error, ServiceRequest),
|
||||
@ -299,6 +302,7 @@ where
|
||||
impl<T> NewService for RouteNewService<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = (Error, ServiceRequest),
|
||||
@ -307,6 +311,7 @@ where
|
||||
T::Service: 'static,
|
||||
<T::Service as Service>::Future: 'static,
|
||||
{
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
|
11
src/scope.rs
11
src/scope.rs
@ -6,7 +6,7 @@ use actix_http::Response;
|
||||
use actix_router::{ResourceDef, ResourceInfo, Router};
|
||||
use actix_service::boxed::{self, BoxedNewService, BoxedService};
|
||||
use actix_service::{
|
||||
ApplyTransform, IntoNewService, IntoTransform, NewService, Service, Transform,
|
||||
apply_transform, IntoNewService, IntoTransform, NewService, Service, Transform,
|
||||
};
|
||||
use futures::future::{ok, Either, Future, FutureResult};
|
||||
use futures::{Async, IntoFuture, Poll};
|
||||
@ -85,6 +85,7 @@ impl Scope {
|
||||
impl<T> Scope<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -188,6 +189,7 @@ where
|
||||
where
|
||||
F: IntoNewService<U>,
|
||||
U: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -218,6 +220,7 @@ where
|
||||
mw: F,
|
||||
) -> Scope<
|
||||
impl NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -234,7 +237,7 @@ where
|
||||
>,
|
||||
F: IntoTransform<M, T::Service>,
|
||||
{
|
||||
let endpoint = ApplyTransform::new(mw, self.endpoint);
|
||||
let endpoint = apply_transform(mw, self.endpoint);
|
||||
Scope {
|
||||
endpoint,
|
||||
rdef: self.rdef,
|
||||
@ -280,6 +283,7 @@ where
|
||||
mw: F,
|
||||
) -> Scope<
|
||||
impl NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -297,6 +301,7 @@ where
|
||||
impl<T> HttpServiceFactory for Scope<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -355,6 +360,7 @@ pub struct ScopeFactory {
|
||||
}
|
||||
|
||||
impl NewService for ScopeFactory {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
@ -515,6 +521,7 @@ impl ScopeEndpoint {
|
||||
}
|
||||
|
||||
impl NewService for ScopeEndpoint {
|
||||
type Config = ();
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
|
@ -51,8 +51,8 @@ struct Config {
|
||||
pub struct HttpServer<F, I, S, B>
|
||||
where
|
||||
F: Fn() -> I + Send + Clone + 'static,
|
||||
I: IntoNewService<S, ServerConfig>,
|
||||
S: NewService<ServerConfig, Request = Request>,
|
||||
I: IntoNewService<S>,
|
||||
S: NewService<Config = ServerConfig, Request = Request>,
|
||||
S::Error: Into<Error>,
|
||||
S::InitError: fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
@ -71,8 +71,8 @@ where
|
||||
impl<F, I, S, B> HttpServer<F, I, S, B>
|
||||
where
|
||||
F: Fn() -> I + Send + Clone + 'static,
|
||||
I: IntoNewService<S, ServerConfig>,
|
||||
S: NewService<ServerConfig, Request = Request>,
|
||||
I: IntoNewService<S>,
|
||||
S: NewService<Config = ServerConfig, Request = Request>,
|
||||
S::Error: Into<Error>,
|
||||
S::InitError: fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
@ -442,8 +442,8 @@ where
|
||||
impl<F, I, S, B> HttpServer<F, I, S, B>
|
||||
where
|
||||
F: Fn() -> I + Send + Clone + 'static,
|
||||
I: IntoNewService<S, ServerConfig>,
|
||||
S: NewService<ServerConfig, Request = Request>,
|
||||
I: IntoNewService<S>,
|
||||
S: NewService<Config = ServerConfig, Request = Request>,
|
||||
S::Error: Into<Error>,
|
||||
S::InitError: fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
|
@ -442,6 +442,7 @@ impl WebService {
|
||||
where
|
||||
F: IntoNewService<T>,
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
@ -467,6 +468,7 @@ struct WebServiceImpl<T> {
|
||||
impl<T> HttpServiceFactory for WebServiceImpl<T>
|
||||
where
|
||||
T: NewService<
|
||||
Config = (),
|
||||
Request = ServiceRequest,
|
||||
Response = ServiceResponse,
|
||||
Error = Error,
|
||||
|
@ -9,7 +9,7 @@ use actix_http::{cookie::Cookie, Extensions, Request};
|
||||
use actix_router::{Path, ResourceDef, Url};
|
||||
use actix_rt::Runtime;
|
||||
use actix_server_config::ServerConfig;
|
||||
use actix_service::{FnService, IntoNewService, NewService, Service};
|
||||
use actix_service::{IntoNewService, IntoService, NewService, Service};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::future::{lazy, ok, Future, IntoFuture};
|
||||
use futures::Stream;
|
||||
@ -110,9 +110,10 @@ pub fn default_service(
|
||||
status_code: StatusCode,
|
||||
) -> impl Service<Request = ServiceRequest, Response = ServiceResponse<Body>, Error = Error>
|
||||
{
|
||||
FnService::new(move |req: ServiceRequest| {
|
||||
(move |req: ServiceRequest| {
|
||||
req.into_response(HttpResponse::build(status_code).finish())
|
||||
})
|
||||
.into_service()
|
||||
}
|
||||
|
||||
/// This method accepts application builder instance, and constructs
|
||||
@ -141,9 +142,9 @@ pub fn init_service<R, S, B, E>(
|
||||
app: R,
|
||||
) -> impl Service<Request = Request, Response = ServiceResponse<B>, Error = E>
|
||||
where
|
||||
R: IntoNewService<S, ServerConfig>,
|
||||
R: IntoNewService<S>,
|
||||
S: NewService<
|
||||
ServerConfig,
|
||||
Config = ServerConfig,
|
||||
Request = Request,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = E,
|
||||
|
Reference in New Issue
Block a user