Class | Rack::Accept::Context |
In: |
lib/rack/accept/context.rb
|
Parent: | Object |
Implements the Rack middleware interface.
app | [R] |
# 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
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 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.
# 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.
# 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.
# File lib/rack/accept/context.rb, line 45 45: def languages=(languages) 46: add_check(:language, languages) 47: end