Class: ERequest
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- ERequest
- Defined in:
- lib/e-core/instance/request.rb
Overview
partially borrowed from Sinatra Framework
Instance Method Summary collapse
-
#accept ⇒ Object
Returns an array of acceptable media types for the response.
- #forwarded? ⇒ Boolean
- #idempotent? ⇒ Boolean
- #preferred_type(*types) ⇒ Object
- #safe? ⇒ Boolean
Instance Method Details
#accept ⇒ Object
Returns an array of acceptable media types for the response
30 31 32 33 |
# File 'lib/e-core/instance/request.rb', line 30 def accept @__e__accept ||= env[EConstants::ENV__HTTP_ACCEPT].to_s.split(','). map {|e| accept_entry(e)}.sort_by {|e| e.last}.map {|e| e.first} end |
#forwarded? ⇒ Boolean
46 47 48 |
# File 'lib/e-core/instance/request.rb', line 46 def forwarded? env.include? EConstants::ENV__HTTP_X_FORWARDED_HOST end |
#idempotent? ⇒ Boolean
54 55 56 |
# File 'lib/e-core/instance/request.rb', line 54 def idempotent? safe? or put? or delete? end |
#preferred_type(*types) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/e-core/instance/request.rb', line 35 def preferred_type(*types) return accept.first if types.empty? types.flatten! accept.detect do |pattern| type = types.detect { |t| File.fnmatch(pattern, t) } return type if type end end |
#safe? ⇒ Boolean
50 51 52 |
# File 'lib/e-core/instance/request.rb', line 50 def safe? get? or head? or or trace? end |