Skip to content

Instantly share code, notes, and snippets.

@dyoder
Created September 29, 2008 17:55
Show Gist options
  • Save dyoder/13640 to your computer and use it in GitHub Desktop.
Save dyoder/13640 to your computer and use it in GitHub Desktop.
# 'html' is the default when there is no extension or Accept header
# we will actually default to json, though ...
Formats = [ :json, :html ]
on( :get, [ :resource ] ) do
# ... do something to get results
format = File.extname( path ); format = 'json' if format.empty?
results.send( "to_#{ format }" )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment