Class: Rack::Lint

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

Overview

Validates your application and the requests and responses according to the Rack spec. See SPEC.rdoc for details.

Defined Under Namespace

Classes: LintError, Wrapper

Constant Summary collapse

ALLOWED_SCHEMES =

:stopdoc:

%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

Constructor Details

#initialize(app) ⇒ Lint

N.B. The empty ‘##` comments creates paragraphs in the output. A trailing “" is used to escape the newline character, which combines the comments into a single paragraph.

Rack Specification

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 test with Rack::Lint to catch possible violations of this specification.

The Application

A Rack application is a Ruby object that responds to call. \

Raises:



65
66
67
68
69
# File 'lib/rack/lint.rb', line 65

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

Invoke the application, validating the request and response according to the Rack spec.



15
16
17
# File 'lib/rack/lint.rb', line 15

def call(env = nil)
  Wrapper.new(@app, env).response
end