Class: Rack::NotFound
- Inherits:
-
Object
- Object
- Rack::NotFound
- Defined in:
- lib/rack/contrib/not_found.rb
Overview
Constant Summary collapse
- F =
::File
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(path = nil, content_type = 'text/html') ⇒ NotFound
constructor
A new instance of NotFound.
Constructor Details
#initialize(path = nil, content_type = 'text/html') ⇒ NotFound
Returns a new instance of NotFound.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rack/contrib/not_found.rb', line 18 def initialize(path = nil, content_type = 'text/html') if path.nil? @content = "Not found\n" else @content = F.read(path) end @length = @content.bytesize.to_s @content_type = content_type end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 |
# File 'lib/rack/contrib/not_found.rb', line 29 def call(env) [404, {'content-type' => @content_type, 'content-length' => @length}, [@content]] end |