Class: Rack::NotFound

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/contrib/not_found.rb

Overview

Rack::NotFound is a default endpoint. Initialize with the path to your 404 page.

Constant Summary collapse

F =
::File

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ NotFound

Returns a new instance of NotFound.



8
9
10
11
12
# File 'lib/rack/contrib/not_found.rb', line 8

def initialize(path)
  file = F.expand_path(path)
  @content = F.read(file)
  @length = @content.size.to_s
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
# File 'lib/rack/contrib/not_found.rb', line 14

def call(env)
  [404, {'Content-Type' => 'text/html', 'Content-Length' => @length}, [@content]]
end