pub async fn init_service_st<St, R, S, E>(
st: St,
app: R,
) -> Pipeline<Request, Response, E>where
St: 'static,
R: IntoServiceFactory<S, St, Request>,
S: ServiceFactory<St, Request, Res = Response, Error = E> + 'static,
S::InitError: Debug,Expand description
This method accepts application builder instance, and constructs service with specified state.
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_st(
(),
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);
}