Simple question which I havn't figured out yet. Is there a way to get the content type of a request in a feathers hook / context?
I read about potentially using express middleware, but I want to still make use of the service, I dont want to replace it with middleware as from what I understand then I cannot make use of a feathers service afterwards.
Any hints/tips/suggestions are welcome.
Regards, Emir
As mentioned in the FAQ it is possible to get access to the request object but it should be avoided because transport specific processing should be kept outside of services (for example, when using Feathers via websockets, there won't be a content type at all).
Service call parameters (params
) for HTTP calls can be set by using a custom Express middleware so you can add a params.contentType
to every service call like this (or use it as a service specific middleware):
app.use(function(req, res, next) {
req.feathers.contentType = req.headers['content-type'];
next();
});