Class Rack::Accept::Context
In: lib/rack/accept/context.rb
Parent: Object

Implements the Rack middleware interface.

Methods

Classes and Modules

Class Rack::Accept::Context::AcceptError

Attributes

app  [R] 

Public Class methods

[Source]

    # File lib/rack/accept/context.rb, line 10
10:     def initialize(app)
11:       @app = app
12:       @checks = {}
13:       @check_headers = []
14:       yield self if block_given?
15:     end

Public Instance methods

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

[Source]

    # File lib/rack/accept/context.rb, line 19
19:     def call(env)
20:       request = env['rack-accept.request'] ||= Request.new(env)
21:       check!(request) unless @checks.empty?
22:       @app.call(env)
23:     rescue AcceptError
24:       response = Response.new
25:       response.not_acceptable!
26:       response.finish
27:     end

Defines the character sets this server is able to serve.

[Source]

    # File lib/rack/accept/context.rb, line 35
35:     def charsets=(charsets)
36:       add_check(:charset, charsets)
37:     end

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

[Source]

    # File lib/rack/accept/context.rb, line 40
40:     def encodings=(encodings)
41:       add_check(:encoding, encodings)
42:     end

Defines the languages this server is able to serve.

[Source]

    # File lib/rack/accept/context.rb, line 45
45:     def languages=(languages)
46:       add_check(:language, languages)
47:     end

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

[Source]

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

[Validate]