class Rack::Queries::App::Static
Constants
- FILES
- STATIC
Attributes
app[R]
server[R]
Public Class Methods
new(app)
click to toggle source
# File lib/rack/queries/app.rb, line 54 def initialize(app) @app = app @server = File.new(STATIC) end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/queries/app.rb, line 59 def call(env) if env[PATH_INFO] == '/' render_index(env) elsif FILES.include?(env[PATH_INFO]) server.call(env) else app.call(env) end end
Private Instance Methods
render_index(env)
click to toggle source
# File lib/rack/queries/app.rb, line 71 def render_index(env) content = ::File.read(::File.join(STATIC, 'index.html.erb')) script_name = env[SCRIPT_NAME] result = ERB.new(content).result_with_hash(script_name: script_name) [200, { 'Content-Type' => 'text/html' }, [result]] end