Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Content negotiation #58
From my understanding it's impossible to do via connect/express middleware, and it could be nice addition to zappa.
And if request has header Accept-type: application/json, server will respond with JSON
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Sounds cool. I like how Rails handle this. It allows for more fine-grained responses.
if err then @next err @format json: => @jsonp user.toJSON() html: => @render index: user.toJSON()
Note that you can just implement this as a helper, no need to integrate this into zappa:
# Call fn if fn is a function call = (fn, ctx, args...) -> if typeof fn is 'function' then fn.apply(ctx || this, args) @helper format: (o) -> switch @request.get 'Content-Type' when 'application/json' then call o.json when 'text/html' then call o.html