Skip to content

Instantly share code, notes, and snippets.

@syntaxritual
Forked from bmizerany/auto-respond-to.rb
Created February 19, 2010 22:19
Show Gist options
  • Save syntaxritual/309286 to your computer and use it in GitHub Desktop.
Save syntaxritual/309286 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