Class: Lurker::Server
- Inherits:
-
Object
- Object
- Lurker::Server
- Defined in:
- lib/lurker/server.rb
Defined Under Namespace
Classes: TryStatic
Class Method Summary collapse
Class Method Details
.to_rack(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/lurker/server.rb', line 28 def self.to_rack( = {}) default_path = [:path] || Lurker::DEFAULT_SERVICE_PATH cls = Class.new(Sinatra::Base) do if !Rails.env.development? && (username, password = .values_at(:username, :password)).all?(&:present?) use ::Rack::Auth::Basic, "Protected Area" do |u, p| username == u && password == p end end use ::Rack::Deflater use TryStatic, :root => "#{::Rails.root}/#{default_path}", # static files root dir :urls => %w[/], # match all requests :header_rules => [ [%w(css js), {'Cache-Control' => 'public, max-age=31536000'}], [:fonts, {'Access-Control-Allow-Origin' => '*'}] ], :try => ['.html', 'index.html', '/index.html'] # try these postfixes sequentially end Lurker.const_set("Rack_#{rand 10}_#{Time.now.to_i}", cls) cls end |