Class: Markdaver::InjectIndexScript

Inherits:
Object
  • Object
show all
Defined in:
lib/markdaver/inject_index_script.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ InjectIndexScript

Returns a new instance of InjectIndexScript.



3
4
5
6
# File 'lib/markdaver/inject_index_script.rb', line 3

def initialize(app, options = {})
  @app = app
  @environment = options[:markdown_editor_env]
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/markdaver/inject_index_script.rb', line 8

def call(env)
  if env["PATH_INFO"] == "/"
    status, header, _ = @app.call env
    header["Content-Length"] = @environment.index.length.to_s
    [status, header, [@environment.index]]
  else
    @app.call env
  end
end