Module: Lowkiq::Web

Defined in:
lib/lowkiq/web.rb,
lib/lowkiq/web/api.rb,
lib/lowkiq/web/action.rb

Defined Under Namespace

Modules: Api Classes: Action

Constant Summary collapse

HTML =
Proc.new do |env|
  root_path = env['SCRIPT_NAME']
  [200, {}, ["    <!DOCTYPE html>\n    <html>\n      <head>\n        <meta charset=\"UTF-8\">\n        <title>Lowkiq</title>\n      </head>\n      <body>\n        <div id=\"root\"></div>\n        <script type=\"text/javascript\">\n          window.lowkiqRoot=\"\#{root_path}\";\n        </script>\n        <script type=\"text/javascript\" src=\"\#{root_path}/assets/\#{VERSION}/app.js\"></script>\n      </body>\n    </html>\n  HTML\nend\n"]]
ASSETS =
File.expand_path("#{File.dirname(__FILE__)}/../../assets")
APP =
Rack::Builder.new do
  map "/api" do
    use Rack::ContentType, "application/json"
    run Api
  end

  map "/assets/#{VERSION}" do
    run Rack::File.new ASSETS, { 'Cache-Control' => 'public, max-age=86400' }
  end

  use Rack::ContentType, "text/html"
  run HTML
end

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



43
44
45
# File 'lib/lowkiq/web.rb', line 43

def self.call(env)
  APP.call env
end