WEBrick::HTTPServlet::AbstractServlet
# File lib/fluent/plugin/in_monitor_agent.rb, line 57 def build_object(req, res) unless req.path_info == "" return render_json_error(404, "Not found") end # parse ?=query string if req.query_string begin qs = CGI.parse(req.query_string) rescue return render_json_error(400, "Invalid query string") end else qs = Hash.new {|h,k| [] } end # if ?debug=1 is set, set :with_debug_info for get_monitor_info # and :pretty_json for render_json_error opts = {} if s = qs['debug'] and s[0] opts[:with_debug_info] = true opts[:pretty_json] = true end if tags = qs['tag'] and tag = tags[0] # ?tag= to search an output plugin by match pattern if obj = @agent.plugin_info_by_tag(tag, opts) list = [obj] else list = [] end elsif plugin_ids = qs['id'] and plugin_id = plugin_ids[0] # ?id= to search a plugin by 'id <plugin_id>' config param if obj = @agent.plugin_info_by_id(plugin_id, opts) list = [obj] else list = [] end elsif types = qs['type'] and type = types[0] # ?type= to search plugins by 'type <type>' config param list = @agent.plugins_info_by_type(type, opts) else # otherwise show all plugins list = @agent.plugins_info_all(opts) end return list, opts end
# File lib/fluent/plugin/in_monitor_agent.rb, line 38 def do_GET(req, res) begin code, header, body = process(req, res) rescue code, header, body = render_json_error(500, { 'message '=> 'Internal Server Error', 'error' => "#{$!}", 'backgrace'=> $!.backtrace, }) end # set response code, header and body res.status = code header.each_pair {|k,v| res[k] = v } res.body = body end
Generated with the Darkfish Rdoc Generator 2.