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.



69
70
71
# File 'opal/lib/opal/cli_runners/server.rb', line 69

def initialize(source)
  @source = source
end

Instance Method Details

#call(env) ⇒ Object



83
84
85
86
87
88
89
90
91
92
# File 'opal/lib/opal/cli_runners/server.rb', line 83

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