Sha256: afa27d84cc68e3892b53163a8352bae4a774180cdb76af2f80b83b293e910412
Contents?: true
Size: 863 Bytes
Versions: 153
Compression:
Stored size: 863 Bytes
Contents
module ActionDispatch # A simple Rack application that renders exceptions in the given public path. class PublicExceptions attr_accessor :public_path def initialize(public_path) @public_path = public_path end def call(env) status = env["PATH_INFO"][1..-1] locale_path = "#{public_path}/#{status}.#{I18n.locale}.html" if I18n.locale path = "#{public_path}/#{status}.html" if locale_path && File.exist?(locale_path) render(status, File.read(locale_path)) elsif File.exist?(path) render(status, File.read(path)) else [404, { "X-Cascade" => "pass" }, []] end end private def render(status, body) [status, {'Content-Type' => "text/html; charset=#{Response.default_charset}", 'Content-Length' => body.bytesize.to_s}, [body]] end end end
Version data entries
153 entries across 114 versions & 18 rubygems