Skip to content

Instantly share code, notes, and snippets.

@attilagyorffy
Created July 22, 2009 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attilagyorffy/151967 to your computer and use it in GitHub Desktop.
Save attilagyorffy/151967 to your computer and use it in GitHub Desktop.
# Free RESTful interface for your Ruby objects with Rackable
# http://github.com/madx/rackable/tree/master
#
# + Free HTTP caching with rack-cache
# http://github.com/rtomayko/rack-cache/tree/master
require 'rackable'
require 'rack/cache'
APP_ROOT = File.dirname(__FILE__)
use Rack::Cache,
:metastore => "file:#{APP_ROOT}/cache/rack/meta",
:entitystore => "file:#{APP_ROOT}/cache/rack/body",
:verbose => true
# Your app
#
class App
include Rackable
def get
cache_long # makes Rack-cache kick in
# just list some files
Dir['./*'].inspect
end
private
def cache_long
rack.header['Cache-Control'] = 'public, max-age=3600'
rack.header['Etag'] = object_id.to_s
end
end
# Save as app.ru and run with:
#
# rackup -p 4000 app.ru
#
run App.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment