In order to support application/json
and multipart/form-data
on the same URL, I would like to check the "Content-Type" header and choose a proper Data<T>
type to hand in to the .data
function of App::new
.
If I uncomment the .guard
line, then curl -X POST -H "Content-Type: multipart/form-data" -F files=\"qqq\" localhost:8080/upload
is dropped. But without the .guard
line all works as it was supposed. What is wrong?
HttpServer::new(move || {
App::new()
.service(resource("/upload")
// .guard(actix_web::guard::Header("Content-Type", "multipart/form-data"))
.data(form.clone())
.route(post()
.to(upload_multipart)
)
)
})
How to join them properly in one instance of App?