Created
January 3, 2013 23:17
-
-
Save statonjr/4448445 to your computer and use it in GitHub Desktop.
Static resource for webmachine-ruby
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 StaticResource < 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 | |
def languages_provided | |
["en-us"] | |
end | |
def resource_exists? | |
File.exists?(request.disp_path) | |
end | |
def content_types_provided | |
[['text/css', :to_css], ['application/javascript', :to_js]] | |
end | |
def to_css | |
File.read(request.disp_path) | |
end | |
def to_js | |
File.read(request.disp_path) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment