Sha256: 8637a9ce97f5e6bb9b2e91019d41f83ff1375b4144434e24e3476080851855c9

Contents?: true

Size: 931 Bytes

Versions: 2

Compression:

Stored size: 931 Bytes

Contents

class Foobara::RailsController < ApplicationController
  before_action :run_and_set_foobara_response

  def run
  end

  def help
  end

  def list
  end

  def describe
  end

  def manifest
  end

  # TODO: add list and describe and manifest if it is different from describe

  private

  def run_and_set_foobara_response
    foobara_response = command_connector.run(self)

    foobara_response.headers.each_pair do |key, value|
      response.set_header(key, value)
    end

    format = if response.content_type == "application/json"
               :json
             else
               :html
             end

    body = foobara_response.body
    # rubocop:disable Rails/OutputSafety
    body = body.html_safe if format == :html
    # rubocop:enable Rails/OutputSafety

    render format => body, status: foobara_response.status
  end

  def command_connector
    Rails.application.config.foobara_command_connector
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foobara-rails-command-connector-0.0.3 lib/foobara/rails/controller.rb
foobara-rails-command-connector-0.0.2 lib/foobara/rails/controller.rb