I am using http.DetectContentType to return the content type o the request but it is returning text/plain is every scenario.
According to the documentation
DetectContentType "... implements the algorithm described at https://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data". The algorithm there is primarily for handling content types which the browser can handle by itself.
And if you look at the actual code you'll see that it does not care about
application/json or similar at all and that it returns
text/plain for anything which looks non-binary (and was not matched before as with
In other words: this is the wrong tool for the job. The proper way would be for the client to specify what kind of content is sent using the
Content-Type header and not to let the server guess the kind of content.