I am using actix-web. I would like to restrict the size of post request and have the web application capture this error log it and send back an informative error message to the user.
My code is given below. It seems the middleware gets run whether or not the limit is exceeded and HTTP code 413 raised. The accept_post is executed only when the limit has not been exceeded.
Is there a way of capturing this error in the middleware?
.service(
web::scope("/hello_someone4")
.service(
web::resource("/there/*")
.app_data(web::PayloadConfig::default().limit(16))
.wrap(simple_middleware::simple_middleware_say_hi::SayHi)
.route(web::post().to(request_handlers2::accept_post))
)
)