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.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rack/contrib/not_found.rb', line 16 def initialize(path = nil, content_type = 'text/html') if path.nil? @content = "Not found\n" else @content = F.read(path) end @length = @content.size.to_s @content_type = content_type end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 |
# File 'lib/rack/contrib/not_found.rb', line 27 def call(env) [404, {'Content-Type' => @content_type, 'Content-Length' => @length}, [@content]] end |