-
-
Save paulcsmith/8eb041acd4efab838d196e7943a76570 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instead of this... | |
before_all "/foo" do |env| | |
puts "Setting response content type" | |
env.response.content_type = "application/json" | |
end | |
# Can I do this.. | |
before_all "/foo", &set_json # where &set_json capture the set_json method | |
get "/foo" do |env| | |
puts env.response.content_type # => "application/json" | |
{"name": "Kemal"}.to_json | |
end | |
def set_json(env) | |
puts "Setting response content type" | |
env.response.content_type = "application/json" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment