Sha256: d881532604110c168a880c471c7bfab25cdd788a342ea7f19e865e6507c77d87

Contents?: true

Size: 924 Bytes

Versions: 20

Compression:

Stored size: 924 Bytes

Contents

class TutorialsController < ApplicationController
  before_action :find_fluentd
  before_action :check_ready, only: [:chapter1, :chapter2]
  before_action :set_in_http, only: [:chapter1, :chapter2, :request_fluentd]
  helper_method :tutorial_ready?

  def index
    @log = @fluentd.agent.log_tail.reverse if @fluentd
  end

  def chapter1
  end

  def chapter2
    @default_conf = Fluentd::DEFAULT_CONF
  end

  def request_fluentd
    HTTPClient.post("http://localhost:#{@in_http["port"]}#{params[:path]}", json: params[:data].to_json)
    render nothing: true, status: 204
  end

  private

  def set_in_http
    @in_http = @fluentd.agent.configuration.sources.find{|directive| directive["type"] == "http"}
  end

  def find_fluentd
    @fluentd = Fluentd.instance
  end

  def check_ready
    redirect_to tutorials_url unless tutorial_ready?
  end

  def tutorial_ready?
    @fluentd && @fluentd.agent.running?
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
fluentd-ui-0.3.14 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.13 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.12 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.11 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.10 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.9 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.8 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.7 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.6 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.5 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.3 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.2 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.1 app/controllers/tutorials_controller.rb
fluentd-ui-0.3.0 app/controllers/tutorials_controller.rb
fluentd-ui-0.2.0 app/controllers/tutorials_controller.rb
fluentd-ui-0.1.4 app/controllers/tutorials_controller.rb
fluentd-ui-0.1.3 app/controllers/tutorials_controller.rb
fluentd-ui-0.1.2 app/controllers/tutorials_controller.rb
fluentd-ui-0.1.1 app/controllers/tutorials_controller.rb
fluentd-ui-0.1.0 app/controllers/tutorials_controller.rb