Skip to content

Instantly share code, notes, and snippets.

@bmizerany
Created February 19, 2010 22:02
Show Gist options
  • Save bmizerany/309267 to your computer and use it in GitHub Desktop.
Save bmizerany/309267 to your computer and use it in GitHub Desktop.
## Pseudo auto-respond-to in Sinatra.
module Sinatra
module AutoRespondTo
def self.registered(app)
app.after do
case request.accept.first
when "application/json"
body { body.to_json }
when "application/xml"
...
end
end
end
end
register AutoRespondTo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment