pub async fn init_service<R, S, E>(app: R) -> Pipeline<Request, Response, E>where
R: IntoServiceFactory<S, (), Request>,
S: ServiceFactory<(), Request, Res = Response, Error = E> + 'static,
S::InitError: Debug,Expand description
This method accepts application builder instance, and constructs service.
use ntex::service::Service;
use ntex::http::StatusCode;
use ntex::web::{self, test, App, HttpResponse};
#[ntex::test]
async fn test_init_service() {
let mut app = test::init_service(
App::new()
.service(web::resource("/test").to(async || { HttpResponse::Ok() }))
).await;
// Create request object
let req = test::TestRequest::with_uri("/test").to_request();
// Execute application
let resp = app.call(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::OK);
}