You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently express-resource uses the :format parameters for matching requested resource format (.xml, .json, etc).
In addition to this, it would be nice to support the HTTP Accept headers. connect-conneg provides a parser for them that organizes the requested formats by preference.
This can already be used with express-resource, but requires some boilerplate. First you need to add the conneg middleware:
And then handle the types in the default content negotiation handler:
default: (req, res, next) ->
for type in req.acceptableTypes
if this.html and type is 'text/html'
return this.html req, res, next
if this.json and type is 'application/json'
return this.json req, res, next
next()
It would be very useful if the default implementation of default did this, instead of falling back to 406 error.
The text was updated successfully, but these errors were encountered:
Currently express-resource uses the
:format
parameters for matching requested resource format (.xml
,.json
, etc).In addition to this, it would be nice to support the HTTP Accept headers. connect-conneg provides a parser for them that organizes the requested formats by preference.
This can already be used with express-resource, but requires some boilerplate. First you need to add the conneg middleware:
And then handle the types in the
default
content negotiation handler:It would be very useful if the default implementation of
default
did this, instead of falling back to406
error.The text was updated successfully, but these errors were encountered: