Kiss A simpler, smarter web application framework for Ruby

Rack::FileNotFound Subclass of Object

Methods

Description

Rack::FileNotFound rescues Kiss::TemplateFileNotFound exceptions (raised when action template files are not found) and returns an HTTP 404 error response.

Public Class Methods

new(app,path = nil) source

Not documented

    # File lib/kiss/rack/file_not_found.rb, line 6
    def initialize(app,path = nil)
      @app = app
      @body = path ? (
        ::File.file?(path) ?
          ::File.read(path) :
          template('could not find specified FileNotFound error document')
        ) : template
    end
    

Public Instance Methods

call(env) source

Not documented

    # File lib/kiss/rack/file_not_found.rb, line 15
    def call(env)
      code, headers, body = @app.call(env)
    rescue Kiss::TemplateFileNotFound => e
      [ 404, {
        "Content-Type" => "text/html",
        "Content-Length" => @body.length.to_s
      }, @body ]
    end
    
template(error = nil) source

Not documented

    # File lib/kiss/rack/file_not_found.rb, line 24
    def template(error = nil)
      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html lang=\"en\">\n<head>\n  <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n  <meta name=\"robots\" content=\"NONE,NOARCHIVE\" />\n  <title>File Not Found</title>\n</head>\n<body>\n<h1>404 File Not Found</h1>\n\n\#{error ? \"<p>Additionally, \#{error}.</p>\" : ''}\n</body>\n</html>\n"
    end
    

Disabled; run with $DEBUG to generate this.