mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
- Add pretty-printing. Doesn't actually work all that well.
This commit is contained in:
parent
74aad9d5da
commit
1a1a3c6000
1 changed files with 12 additions and 13 deletions
|
@ -28,7 +28,7 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
set :views, "#{File.dirname(__FILE__)}/views"
|
set :views, "#{File.dirname(__FILE__)}/views"
|
||||||
|
|
||||||
use Rack::CommonLogger
|
use Rack::CommonLogger
|
||||||
#use Rack::ShowExceptions
|
use Rack::ShowExceptions
|
||||||
|
|
||||||
def initialize(settings={})
|
def initialize(settings={})
|
||||||
super
|
super
|
||||||
|
@ -154,11 +154,7 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
when "json"
|
when "json"
|
||||||
headers({"Content-Type" => "text/plain" })
|
headers({"Content-Type" => "text/plain" })
|
||||||
# TODO(sissel): issue/30 - needs refactoring here.
|
# TODO(sissel): issue/30 - needs refactoring here.
|
||||||
if @results.error?
|
body({ "error" => @results.error_message }.to_json)
|
||||||
body({ "error" => @results.error_message }.to_json)
|
|
||||||
else
|
|
||||||
body @results.to_json
|
|
||||||
end
|
|
||||||
end # case params[:format]
|
end # case params[:format]
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -212,10 +208,13 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
body erb :"search/results.txt", :layout => false
|
body erb :"search/results.txt", :layout => false
|
||||||
when "json"
|
when "json"
|
||||||
headers({"Content-Type" => "text/plain" })
|
headers({"Content-Type" => "text/plain" })
|
||||||
# TODO(sissel): issue/30 - needs refactoring here.
|
pretty = params.has_key?("pretty")
|
||||||
response = @results
|
if pretty
|
||||||
p response.to_hash
|
#ap :fields => @results.events.first.fields
|
||||||
body response.to_json
|
body JSON.pretty_generate(@results.to_hash)
|
||||||
|
else
|
||||||
|
body @results.to_json
|
||||||
|
end
|
||||||
end # case params[:format]
|
end # case params[:format]
|
||||||
end # @backend.search
|
end # @backend.search
|
||||||
end # def api_search
|
end # def api_search
|
||||||
|
@ -319,7 +318,7 @@ end
|
||||||
|
|
||||||
#Rack::Handler::Thin.run(
|
#Rack::Handler::Thin.run(
|
||||||
Mizuno::HttpServer.run(
|
Mizuno::HttpServer.run(
|
||||||
Rack::CommonLogger.new( \
|
#Rack::CommonLogger.new( \
|
||||||
Rack::ShowExceptions.new( \
|
#Rack::ShowExceptions.new( \
|
||||||
LogStash::Web::Server.new(settings))),
|
LogStash::Web::Server.new(settings),
|
||||||
:Port => settings.port, :Host => settings.address)
|
:Port => settings.port, :Host => settings.address)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue