Sha256: 2688a7db343cee6073d2b6f3c59b7e6167c1e2028df5d1bc219ee8690cb7e3a3

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require "logstash/api/app_helpers"
require "logstash/api/command_factory"

module LogStash
  module Api
    module Modules
      class Base < ::Sinatra::Base
        helpers AppHelpers

        set :environment, :production

        attr_reader :factory

        if settings.environment != :production
          set :raise_errors, true
          set :show_exceptions, :after_handler
        end

        include LogStash::Util::Loggable

        helpers AppHelpers

        def initialize(app=nil)
          super(app)
          @factory = ::LogStash::Api::CommandFactory.new(LogStash::Api::Service.instance)
        end

        not_found do
          status 404
          as   = params.has_key?("human") ? :string : :json
          text = as == :string ? "" : {}
          respond_with(text, :as => as)
        end

        error do
          e = env['sinatra.error']
          logger.error(e.message, :url => request.url, :ip => request.ip, :params => request.params, :class => e.class.name, :backtrace => e.backtrace)
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-core-5.0.0.alpha3-java lib/logstash/api/modules/base.rb
logstash-core-5.0.0.alpha3.snapshot8-java lib/logstash/api/modules/base.rb
logstash-core-5.0.0.alpha3.snapshot7-java lib/logstash/api/modules/base.rb