Class: Rack::Lint
- Inherits:
-
Object
- Object
- Rack::Lint
- Defined in:
- lib/rack/lint.rb
Overview
Rack::Lint validates your application and the requests and responses according to the Rack spec.
Defined Under Namespace
Constant Summary collapse
- ALLOWED_SCHEMES =
%w(https http wss ws).freeze
- REQUEST_PATH_ORIGIN_FORM =
/\A\/[^#]*\z/
- REQUEST_PATH_ABSOLUTE_FORM =
/\A#{Utils::URI_PARSER.make_regexp}\z/
- REQUEST_PATH_AUTHORITY_FORM =
/\A[^\/:]+:\d+\z/
- REQUEST_PATH_ASTERISK_FORM =
'*'
Instance Method Summary collapse
- #call(env = nil) ⇒ Object
-
#initialize(app) ⇒ Lint
constructor
AUTHORS: n.b.
Constructor Details
#initialize(app) ⇒ Lint
AUTHORS: n.b. The trailing whitespace between paragraphs is important and should not be removed. The whitespace creates paragraphs in the RDoc output.
This specification aims to formalize the Rack protocol. You can (and should) use Rack::Lint to enforce it.
When you develop middleware, be sure to add a Lint before and after to catch all mistakes.
Rack applications
A Rack application is a Ruby object (not a class) that responds to call
.
38 39 40 41 42 |
# File 'lib/rack/lint.rb', line 38 def initialize(app) raise LintError, "app must respond to call" unless app.respond_to?(:call) @app = app end |
Instance Method Details
#call(env = nil) ⇒ Object
44 45 46 |
# File 'lib/rack/lint.rb', line 44 def call(env = nil) Wrapper.new(@app, env).response end |