Sha256: 37f2c158d54f2950ce57c6f1fe29d9b4d9341b78a9e214a8217da4efbb2cdb91

Contents?: true

Size: 932 Bytes

Versions: 9

Compression:

Stored size: 932 Bytes

Contents

require "rack/mime"

# Works for utf8 text files.
# TODO: Add support to public_controller for binary data like images.
# Tricky because API Gateway is not respecting the Accept header in the
# same way as browsers.
class Jets::PublicController < Jets::Controller::Base
  layout false
  internal true

  # # Use python until ruby support is added.
  # python :show

  if Jets::Commands::Build.poly_only?
    # Use python if poly only so we don't have to upload rubuy
    python :show
  else
    # TODO: When ruby support is relesed, switch to it only.
    def show
      public_path = Jets.root + "public"
      catchall_path = "#{public_path}/#{params[:catchall]}"
      if File.exist?(catchall_path)
        content_type = Rack::Mime.mime_type(File.extname(catchall_path))
        render file: catchall_path, content_type: content_type
      else
        render file: "#{public_path}/404", status: 404
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jets-0.5.8 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.7 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.6 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.5 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.4 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.3 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.2 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.1 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.5.0 lib/jets/internal/app/controllers/jets/public_controller.rb