pub fn service<S, E>(mut self, service_factory: S) -> Self
    where
        S: ServiceFactory<
                ServiceRequest,
                Response = ServiceResponse,
                Error = E,
                InitError = (),
                Config = (),
            > + 'static,
        E: Into<Error> + 'static,
    {
        self.service = boxed::factory(service_factory.map_err(Into::into));
        self
    }
/// Set raw service to be constructed and called as the request handler.
///
/// # Examples
/// ```
/// # use std::convert::Infallible;
/// # use futures_util::future::LocalBoxFuture;
/// # use actix_web::{*, dev::*, http::header};
/// struct HelloWorld;
///
/// impl Service<ServiceRequest> for HelloWorld {
///     type Response = ServiceResponse;
///     type Error = Infallible;
///     type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
///
///     always_ready!();
///
///     fn call(&self, req: ServiceRequest) -> Self::Future {
///         let (req, _) = req.into_parts();
///
///         let res = HttpResponse::Ok()
///             .insert_header(header::ContentType::plaintext())
///             .body("Hello world!");
///
///         Box::pin(async move { Ok(ServiceResponse::new(req, res)) })
///     }
/// }
///
/// App::new().route(
///     "/",
///     web::get().service(fn_factory(|| async { Ok(HelloWorld) })),
/// );
/// ```
Set raw service to be constructed and called as the request handler.
Set raw service to be constructed and called as the request handler .
pub fn service<S, E>(mut self, service_factory: S) -> Self
    where
        S: ServiceFactory<
                ServiceRequest,
                Response = ServiceResponse,
                Error = E,
                InitError = (),
                Config = (),
            > + 'static,
        E: Into<Error> + 'static,
    {
        self.service = boxed::factory(service_factory.map_err(Into::into));
        self
    }
pub fn service < S , E > ( mut self , service_factory : S ) -> Self where S : ServiceFactory < ServiceRequest , Response = ServiceResponse , Error = E , InitError = ( ) , Config = ( ) , > + ' static , E : Into < Error > + ' static , { self . service = boxed :: factory ( service_factory . map_err ( Into :: into ) ) ; self }
Set raw service to be constructed and called as the request handler.
Set raw service to be constructed and called as the request handler .
mut self
service_factory
S
mut self
service_factory
S
examples
None
use std::convert::infallible;
None
use futures_util::future::localboxfuture;
None
use actix_web::{*, dev::*, http::header};
struct HelloWorld.

impl Service for HelloWorld {
type Response = ServiceResponse;
type Error = Infallible;
type Future = LocalBoxFuture<'static, Result>.



fn call(&self, req: ServiceRequest) -> Self::Future {
let (req, _) = req.into_parts().

let res = HttpResponse::Ok()
.insert_header(header::ContentType::plaintext())
.body("Hello world!").

:pin(async move { Ok(ServiceResponse::new(req, res)) })
}
}


struct HelloWorld . impl Service for HelloWorld { type Response = ServiceResponse ; type Error = Infallible ; type Future = LocalBoxFuture< ' static Result > . fn call ( &self req : ServiceRequest ) - > Self :: Future { let ( req _ ) = req . into_parts () . let res = HttpResponse :: Ok () . insert_header ( header :: ContentType :: plaintext () ) . body ( " Hello world! " ) . : pin ( async move { Ok ( ServiceResponse :: new ( req res )) } ) } }