class BridgetownPluginNano::Middleware::NotFound
Public Class Methods
new(app, path, content_type = "text/html; charset=utf-8")
click to toggle source
# File lib/bridgetown-plugin-nano/rack_middleware/not_found.rb, line 6 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/bridgetown-plugin-nano/rack_middleware/not_found.rb, line 13 def call(env) response = @app.call(env) if response[0] == 404 [404, { "Content-Type" => @content_type, "Content-Length" => @length }, [@content]] else response end end