Skip to content

Instantly share code, notes, and snippets.

@mostlyobvious
Created April 10, 2012 16:05
Show Gist options
  • Save mostlyobvious/2352430 to your computer and use it in GitHub Desktop.
Save mostlyobvious/2352430 to your computer and use it in GitHub Desktop.
# $ curl -i -H 'Accept: application/vnd.helloapp-v2+json' http://localhost:8080/hello/prug
#
# HTTP/1.1 200 OK
# Content-Type: application/vnd.helloapp-v2+json
# Vary: Accept
# Content-Length: 11
# Server: Webmachine-Ruby/0.3.0 WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
# Date: Thu, 26 Jan 2012 15:27:09 GMT
# Connection: Keep-Alive
#
# Nay! Hello
class HelloResource < Webmachine::Resource
def content_types_provided
[['application/vnd.helloapp-v1+json', :to_representation_yay],
['application/vnd.helloapp-v2+json', :to_representation_nay]]
end
def to_representation_yay
"Yay! Hello #{request.path_info[:id]}"
end
def to_representation_nay
"Nay! Hello #{request.path_info[:id]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment