Sha256: 7677ab23057869697548387a17e2772870baa746f47e803e6bc5916e94b4743a

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

class WebSystem::RackPanel < Liza::Panel

  def call strategy, host, port
    puts
    log({strategy:, host:, port:})

    strategy ||= get :strategy
    host ||= get :host
    port ||= 3000
    files ||= get :files

    log({strategy:, host:, port:})

    x = App.mode == :code ? "development" : "production"
    ENV["RACK_ENV"] = x
    rack_app = send "get_rack_app_#{x}"

    rack_files = Object::Rack::Files.new files
    rack_app = Object::Rack::Cascade.new [rack_files, rack_app]

    # TODO: PumaRack
    # handler = Liza.const(:"#{strategy}_rack")

    require "rack/handler/puma"
    handler = Object::Rack::Handler::Puma
    handler.run rack_app, Host: host, Port: port
  end

  def get_rack_app_production()= WebBox[:request]

  def get_rack_app_development
    Proc.new do |env|
      ret = nil
      App.reload do
        log "reloading"
        ret = get_rack_app_production.call env
      end
      ret
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lizarb-1.0.4 lib/web_system/web/panels/rack_panel.rb
lizarb-1.0.3 lib/web_system/web/panels/rack_panel.rb