Function ajars_actix_web::actix_web::test::init_service [−][src]
pub async fn init_service<R, S, B, E>(
app: R
) -> impl Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>, Response = ServiceResponse<B>, Error = E> where
R: IntoServiceFactory<S, Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>,
S: ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>, Config = AppConfig, Response = ServiceResponse<B>, Error = E>,
<S as ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::InitError: Debug,
Expand description
Initialize service from application builder instance.
use actix_service::Service; use actix_web::{test, web, App, HttpResponse, http::StatusCode}; #[actix_rt::test] async fn test_init_service() { let 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); }