1
0
mirror of https://github.com/actix/examples synced 2024-11-30 17:14:35 +01:00

Improve json_decode_error example. (#363)

* Improve json_decode_error example.

* Remove 'Per-type' JsonConfig.
This commit is contained in:
Robert Gabriel Jakabosky 2020-09-11 15:31:34 +08:00 committed by GitHub
parent adccbe2a13
commit 20d7af6c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
use actix_web::{
error, post, web, App, FromRequest, HttpRequest, HttpResponse, HttpServer, Responder,
error, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder,
};
use serde::Deserialize;
@ -34,9 +34,9 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(greet)
.app_data(web::Json::<Info>::configure(|cfg| {
cfg.error_handler(json_error_handler)
}))
.app_data(web::JsonConfig::default()
.error_handler(json_error_handler)
) // <- register error_handler for JSON extractors.
})
.bind("127.0.0.1:8088")?
.run()