[−][src]Function actix_web::test::init_service
pub fn init_service<R, S, B, E>(
app: R
) -> impl Service<Request = Request, Response = ServiceResponse<B>, Error = E> where
R: IntoNewService<S, ServerConfig>,
S: NewService<ServerConfig, Request = Request, Response = ServiceResponse<B>, Error = E>,
S::InitError: Debug,
This method accepts application builder instance, and constructs service.
use actix_service::Service; use actix_web::{test, web, App, HttpResponse, http::StatusCode}; #[test] fn test_init_service() { let mut app = test::init_service( App::new() .service(web::resource("/test").to(|| HttpResponse::Ok())) ); // Create request object let req = test::TestRequest::with_uri("/test").to_request(); // Execute application let resp = test::block_on(app.call(req)).unwrap(); assert_eq!(resp.status(), StatusCode::OK); }