Class: Lilac::CLI::DevServer::RoutingApp

Inherits:
Object
  • Object
show all
Defined in:
lib/lilac/cli/dev_server.rb

Overview

Wsv app that routes one path to live_reload, everything else to default_app. Lives here because it's only useful as the dev server's request demultiplexer.

Instance Method Summary collapse

Constructor Details

#initialize(default_app:, live_reload:, endpoint:) ⇒ RoutingApp

Returns a new instance of RoutingApp.



139
140
141
142
143
# File 'lib/lilac/cli/dev_server.rb', line 139

def initialize(default_app:, live_reload:, endpoint:)
  @default_app = default_app
  @live_reload = live_reload
  @endpoint = endpoint
end

Instance Method Details

#call(request) ⇒ Object



145
146
147
148
149
150
151
152
# File 'lib/lilac/cli/dev_server.rb', line 145

def call(request)
  path, = request.target.split("?", 2)
  if path == @endpoint
    @live_reload.call(request)
  else
    @default_app.call(request)
  end
end