mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
Improve json_decode_error example. (#363)
* Improve json_decode_error example. * Remove 'Per-type' JsonConfig.
This commit is contained in:
parent
adccbe2a13
commit
20d7af6c27
@ -1,5 +1,5 @@
|
|||||||
use actix_web::{
|
use actix_web::{
|
||||||
error, post, web, App, FromRequest, HttpRequest, HttpResponse, HttpServer, Responder,
|
error, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ async fn main() -> std::io::Result<()> {
|
|||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.service(greet)
|
.service(greet)
|
||||||
.app_data(web::Json::<Info>::configure(|cfg| {
|
.app_data(web::JsonConfig::default()
|
||||||
cfg.error_handler(json_error_handler)
|
.error_handler(json_error_handler)
|
||||||
}))
|
) // <- register error_handler for JSON extractors.
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")?
|
.bind("127.0.0.1:8088")?
|
||||||
.run()
|
.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user