Last active
December 23, 2015 22:39
-
-
Save statonjr/6704915 to your computer and use it in GitHub Desktop.
Musings on an API
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
class DealershipsResource < Webmachine::Resource | |
def encodings_provided | |
{"gzip" => :encode_gzip, "identity" => :encode_identity} | |
end | |
def allowed_methods | |
%W[GET] | |
end | |
def generate_etag | |
Digest::MD5.hexdigest(Time.now.utc.to_i.to_s + request.body.to_s) | |
end | |
# See https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/resource/callbacks.rb#L28 | |
def is_authorized?(authorization_header = nil) | |
true | |
end | |
def languages_provided | |
["en-us"] | |
end | |
def resource_exists? | |
true | |
end | |
def content_types_provided | |
[['text/csv', :to_csv], ['application/xml', :to_xml], ['text/html', :to_html]] | |
end | |
def to_csv | |
# Return representation of this resource as CSV | |
end | |
def to_xml | |
# Return representation of this resource as XML | |
end | |
def to_html | |
# Return representation of this resource as HTML | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment