Sha256: 51da0732e3e484df16659899fa88b0edc814bb3a5005769acd8e222b699360e7

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

require 'rails-reverse-proxy'

module Quilt
  module ReactRenderable
    include ReverseProxy::Controller

    def render_react
      url = "#{Quilt.configuration.react_server_protocol}://#{Quilt.configuration.react_server_host}"
      ReactRenderable.log("[ReactRenderable] proxying to React server at #{url}")

      reverse_proxy(url) do |callbacks|
        callbacks.on_response do |status_code, _response|
          ReactRenderable.log("[ReactRenderable] #{url} returned #{status_code}")
        end
      end
    end

    def self.log(string)
      if Rails.logger.nil?
        puts string
      else
        Rails.logger.info(string)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quilt_rails-1.3.2 lib/quilt_rails/react_renderable.rb
quilt_rails-1.3.1 lib/quilt_rails/react_renderable.rb