Parent

Files

Rack::Accept::Context

Implements the Rack middleware interface.

Attributes

app[R]

Public Class Methods

new(app) click to toggle source
# File lib/rack/accept/context.rb, line 10
def initialize(app)
  @app = app
  @checks = {}
  @check_headers = []
  yield self if block_given?
end

Public Instance Methods

call(env) click to toggle source

Inserts a new Rack::Accept::Request object into the environment before handing the request to the app immediately downstream.

# File lib/rack/accept/context.rb, line 19
def call(env)
  request = env['rack-accept.request'] ||= Request.new(env)
  check!(request) unless @checks.empty?
  @app.call(env)
rescue AcceptError
  response = Response.new
  response.not_acceptable!
  response.finish
end
charsets=(charsets) click to toggle source

Defines the character sets this server is able to serve.

# File lib/rack/accept/context.rb, line 35
def charsets=(charsets)
  add_check(:charset, charsets)
end
encodings=(encodings) click to toggle source

Defines the types of encodings this server is able to serve.

# File lib/rack/accept/context.rb, line 40
def encodings=(encodings)
  add_check(:encoding, encodings)
end
languages=(languages) click to toggle source

Defines the languages this server is able to serve.

# File lib/rack/accept/context.rb, line 45
def languages=(languages)
  add_check(:language, languages)
end
media_types=(media_types) click to toggle source

Defines the types of media this server is able to serve.

# File lib/rack/accept/context.rb, line 30
def media_types=(media_types)
  add_check(:media_type, media_types)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.