Sha256: bda33dd05218f0105d450fbe571f93b96e77e24927cef55c1addd27dd0377086

Contents?: true

Size: 1.31 KB

Versions: 27

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
require "logstash/api/app_helpers"
require "logstash/api/command_factory"
require "logstash/api/errors"

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

        helpers AppHelpers

        # These options never change
        # Sinatra isn't good at letting you change internal settings at runtime
        # which is a requirement. We always propagate errors up and catch them
        # in a custom rack handler in the RackApp class
        set :environment, :production
        set :raise_errors, true
        set :show_exceptions, false

        attr_reader :factory, :agent

        include LogStash::Util::Loggable

        helpers AppHelpers

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

        not_found do
          # We cannot raise here because it wont be catched by the `error` handler.
          # So we manually create a new instance of NotFound and just pass it down.
          respond_with(NotFoundError.new)
        end

        # This allow to have custom exception but keep a consistent
        # format to report them.
        error ApiError do |error|
          respond_with(error)
        end
      end
    end
  end
end

Version data entries

27 entries across 26 versions & 7 rubygems

Version Path
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/api/modules/base.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/api/modules/base.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/logstash-core-5.0.0-java/lib/logstash/api/modules/base.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/logstash-core-5.2.1-java/lib/logstash/api/modules/base.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/api/modules/base.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.2.1-java/lib/logstash/api/modules/base.rb
logstash-core-5.3.3-java lib/logstash/api/modules/base.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/logstash-core-5.2.1-java/lib/logstash/api/modules/base.rb
logstash-core-5.3.2-java lib/logstash/api/modules/base.rb
logstash-core-5.3.1-java lib/logstash/api/modules/base.rb
logstash-core-5.3.0-java lib/logstash/api/modules/base.rb
logstash-core-5.2.2-java lib/logstash/api/modules/base.rb
logstash-input-fifo-0.9.1 vendor/bundle/jruby/1.9/gems/logstash-core-5.1.1.1-java/lib/logstash/api/modules/base.rb
logstash-input-fifo-0.9.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.1.1.1-java/lib/logstash/api/modules/base.rb
logstash-core-5.2.1-java lib/logstash/api/modules/base.rb
logstash-core-5.2.0-java lib/logstash/api/modules/base.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/logstash-core-5.1.1.1-java/lib/logstash/api/modules/base.rb
logstash-core-5.1.2-java lib/logstash/api/modules/base.rb
logstash-core-5.1.1.1-java lib/logstash/api/modules/base.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/logstash-core-5.1.2.snapshot1-java/lib/logstash/api/modules/base.rb