Is it possible (or sensible) to build a custom MediaTypeMapping
to select a MediaTypeFormatter
based on content from the Request Body?
I'm thinking specifically of a case where I have a very non-descriptive text/plain in a multipart/form-data payload and I want to use heuristics to work out what's contained.
I'm currently doing this in a custom MediaTypeFormatter
that looks at the first few lines, and if the content begins with {
then it assumes JSON, if it's word,word,word
the the commas indicate CSV.
I was thinking that a MediaTypeMapping
would be cleaner but I don't know if it's sensible to try and match from the Body content.