1
0
mirror of https://github.com/actix/actix-website synced 2024-11-27 18:12:57 +01:00

updates flexible responders.

This commit is contained in:
Cameron Dershem 2019-06-28 12:09:51 -04:00
parent 4833874c5d
commit cbf046b1f0
2 changed files with 3 additions and 2 deletions

View File

@ -11,7 +11,7 @@ fn hello_world() -> impl Responder {
"Hello World!" "Hello World!"
} }
fn current_temperature(_req: HttpRequest) -> impl Responder { fn current_temperature() -> impl Responder {
web::Json(Measurement { temperature: 42.3 }) web::Json(Measurement { temperature: 42.3 })
} }

View File

@ -70,6 +70,7 @@ fn main() {
to return consistent responses from your APIs. to return consistent responses from your APIs.
</p> </p>
{{ highlight `#[derive(Serialize)] {{ highlight `#[derive(Serialize)]
#[derive(Serialize)]
struct Measurement { struct Measurement {
temperature: f32, temperature: f32,
} }
@ -78,7 +79,7 @@ fn hello_world() -> impl Responder {
"Hello World!" "Hello World!"
} }
fn current_temperature(_req: HttpRequest) -> impl Responder { fn current_temperature() -> impl Responder {
web::Json(Measurement { temperature: 42.3 }) web::Json(Measurement { temperature: 42.3 })
}` "rust" "" }} }` "rust" "" }}
</div> </div>