class Markdaver::InjectIndexScript

Public Class Methods

new(app, options = {}) click to toggle source
# File lib/markdaver/inject_index_script.rb, line 3
def initialize(app, options = {})
  @app = app
  @environment = options[:markdown_editor_env]
end

Public Instance Methods

call(env) click to toggle source
# 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