Class: LogStash::Kibana::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/logstash/kibana.rb

Instance Method Summary collapse

Instance Method Details

#static_fileObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/logstash/kibana.rb', line 38

def static_file
  # request.path_info is the full path of the request.
  docroot =  File.expand_path(File.join(File.dirname(__FILE__), "../../vendor/kibana"))
  path = File.join(docroot, *request.path_info.split("/"))
  if File.exists?(path)
    ext = path.split(".").last
    content_type MIME::Types.type_for(ext).first.to_s
    body File.new(path, "r").read
  else
    status 404
    content_type "text/plain"
    body "File not found: #{path}"
  end
end