I would like to support a couple of different content types submitted to the same URL:
e.g:
application/x-www-form-urlencoded
, multipart/form-data
, application/json
I would like to do something like:
post {
contentType(`application/x-www-form-urlencoded`) |
contentType(`multipart/form-data`) {
// user POSTed a form
entity(as[MyCaseClass]) { data =>
complete { data.result }
}
} ~ contentType(`application/json`) {
// user POSTed a JSON object
entity(as[MyCaseClass]) { data =>
complete { data.result }
}
}
}
I think there may be some way to do this with custom marshaling and unmarshaling, but I only need it in one or two spots in my service and this seems pretty simple. Can someone help?
application/json
no matter what format the request came in. – Deltoro