mirror of https://github.com/fafhrd91/actix-web
modied docs for read_response_json
This commit is contained in:
parent
5745a7a67a
commit
67e9c72039
29
src/test.rs
29
src/test.rs
|
@ -371,17 +371,30 @@ impl TestRequest {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::{App, test};
|
/// use actix_web::{App, test};
|
||||||
|
/// use serde::{Serialize, Deserialize};
|
||||||
///
|
///
|
||||||
/// let mut app = test::init_service(App::new());
|
/// #[derive(Serialize, Deserialize)]
|
||||||
/// let payload = r#"{"id":"12345","name":"Nikolay Kim"}"#.as_bytes();
|
/// pub struct Person { id: String, name: String }
|
||||||
///
|
///
|
||||||
/// let req = test::TestRequest::post()
|
/// #[test]
|
||||||
/// .uri("/people")
|
/// fn test_add_person() {
|
||||||
/// .header(header::CONTENT_TYPE, "application/json")
|
/// let mut app = test::init_service(App::new().service(
|
||||||
/// .set_payload(payload)
|
/// web::resource("/people")
|
||||||
/// .to_request();
|
/// .route(web::post().to(|person: Json<Person>| {
|
||||||
|
/// HttpResponse::Ok()
|
||||||
|
/// .json(person.into_inner())})
|
||||||
|
/// )));
|
||||||
///
|
///
|
||||||
/// let result = read_response_json<_, _, _, serde_json::Value>(&mut app, req);
|
/// let payload = r#"{"id":"12345","name":"Nikolay Kim"}"#.as_bytes();
|
||||||
|
///
|
||||||
|
/// let req = test::TestRequest::post()
|
||||||
|
/// .uri("/people")
|
||||||
|
/// .header(header::CONTENT_TYPE, "application/json")
|
||||||
|
/// .set_payload(payload)
|
||||||
|
/// .to_request();
|
||||||
|
///
|
||||||
|
/// let result = read_response_json<_, _, _, Person>(&mut app, req);
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn read_response_json<S, R, B, T>(app: &mut S, req: R) -> T
|
pub fn read_response_json<S, R, B, T>(app: &mut S, req: R) -> T
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in New Issue