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, {}, [<<-HTML]]
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <title>Lowkiq</title>
      </head>
      <body>
        <div id="root"></div>
        <script type="text/javascript">
          window.lowkiqRoot="#{root_path}";
        </script>
        <script type="text/javascript" src="#{root_path}/assets/#{VERSION}/app.js"></script>
      </body>
    </html>
  HTML
end
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