Skip to content

Commit

Permalink
docs(actix-http-test): update test server example (actix#3007)
Browse files Browse the repository at this point in the history
  • Loading branch information
tltsutltsu authored Mar 31, 2023
1 parent e68f87f commit 8dee8a1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions actix-http-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,29 @@ use tokio::sync::mpsc;
/// ```no_run
/// use actix_http::HttpService;
/// use actix_http_test::test_server;
/// use actix_web::{web, App, HttpResponse, Error};
/// use actix_service::map_config;
/// use actix_service::ServiceFactoryExt;
/// use actix_web::{dev::AppConfig, web, App, Error, HttpResponse};
///
/// async fn my_handler() -> Result<HttpResponse, Error> {
/// Ok(HttpResponse::Ok().into())
/// }
///
/// #[actix_web::test]
/// async fn test_example() {
/// let mut srv = TestServer::start(||
/// HttpService::new(
/// App::new().service(web::resource("/").to(my_handler))
/// )
/// );
/// let srv = test_server(|| {
/// let app = App::new().service(web::resource("/").to(my_handler));
///
/// HttpService::build()
/// .h1(map_config(app, |_| AppConfig::default()))
/// .tcp()
/// .map_err(|_| ())
/// })
/// .await;
///
/// let req = srv.get("/");
/// let response = req.send().await.unwrap();
///
/// assert!(response.status().is_success());
/// }
/// ```
Expand Down

0 comments on commit 8dee8a1

Please sign in to comment.