Class: Opal::CliRunners::Server::App

Inherits:
Object
  • Object
show all
Defined in:
opal/lib/opal/cli_runners/server.rb

Constant Summary collapse

BODY =
<<-HTML
  <!doctype html>
  <html>
    <head>
      <meta charset="utf-8"/>
      <script src="/cli_runner.js"></script>
    </head>
  </html>
HTML

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ App

Returns a new instance of App.



57
58
59
# File 'opal/lib/opal/cli_runners/server.rb', line 57

def initialize(source)
  @source = source
end

Instance Method Details

#call(env) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'opal/lib/opal/cli_runners/server.rb', line 71

def call(env)
  case env['PATH_INFO']
  when '/'
    [200, { 'Content-Type' => 'text/html' }, [BODY]]
  when '/cli_runner.js'
    [200, { 'Content-Type' => 'text/javascript' }, [@source]]
  else
    [404, {}, ['not found']]
  end
end