Sha256: e2162e31666e1f652be9b3e28700186851d1791d9a3488f6da9288580f35faec
Contents?: true
Size: 821 Bytes
Versions: 5
Compression:
Stored size: 821 Bytes
Contents
# frozen_string_literal: true module NextRailsScaffold class StaticPagesController < ApplicationController STATIC_FILES_PATH = Rails.root.join("public").to_s def index send_file file_path, type: "text/html", disposition: "inline" rescue ActionController::ResourceNotFound send_file File.join(STATIC_FILES_PATH, "404.html"), type: "text/html", disposition: "inline", status: 404 rescue StandardError => e Rails.logger.error "StaticPagesController (#{e.class}): #{e.message}" raise e end private def file_path path = params.require(:file_path) raise ActionController::ResourceNotFound, "Not Found" unless File.exist?(path) raise ActionController::RoutingError, "Forbidden" unless path.start_with?(STATIC_FILES_PATH) path end end end
Version data entries
5 entries across 5 versions & 1 rubygems