class Phaedra::Middleware::NotFound
Public Class Methods
new(app, path, content_type = 'text/html; charset=utf-8')
click to toggle source
# File lib/phaedra/rack_middleware/not_found.rb, line 4 def initialize(app, path, content_type = 'text/html; charset=utf-8') @app = app @content = File.read(path) @length = @content.bytesize.to_s @content_type = content_type end
Public Instance Methods
call(env)
click to toggle source
# File lib/phaedra/rack_middleware/not_found.rb, line 11 def call(env) response = @app.call(env) if response[0] == 404 [404, {'Content-Type' => @content_type, 'Content-Length' => @length}, [@content]] else response end end