Skip to content

Instantly share code, notes, and snippets.

@IdahoEv
Created January 29, 2015 00:29
Show Gist options
  • Select an option

  • Save IdahoEv/35a0264f2ab1ba9e572d to your computer and use it in GitHub Desktop.

Select an option

Save IdahoEv/35a0264f2ab1ba9e572d to your computer and use it in GitHub Desktop.
module LrdCms2
class StaticLogger < ::Logger
# needed to use stdlib logger with Rack < 1.6.0
def write(msg)
self.<<(msg)
end
end
class StaticApp
def self.build(root_path, backend_port)
backend_url = "http://localhost:#{backend_port}/"
env = ENV['RAILS_ENV'] || 'development'
logger = StaticLogger.new(Rails.root.join("log/#{env}_static.log"))
Rack::Builder.new do
use BackendUrlCookie, backend_url
use GotoParam
use Rack::CommonLogger, logger
use Rack::Static, {
:urls => [""],
:root => root_path,
:index => "index.html",
:header_rules => {
:all => {"Cache-Control" => "no-cache, max-age=0" } #no caching development assets
}
}
run proc{}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment