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::{
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user