lib/merb/merb_request.rb in merb-0.1.0 vs lib/merb/merb_request.rb in merb-0.2.0
- old
+ new
@@ -1,9 +1,9 @@
module Merb
class Request
-
+ attr_accessor :env
def initialize(env, method)
@env = env
@method = method
end
@@ -38,15 +38,24 @@
# returns true if the request is an SSL request
def ssl?
@env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
end
+ # returns the request HTTP_REFERER.
+ def referer
+ @env['HTTP_REFERER']
+ end
+
# returns he request uri.
def uri
@env['REQUEST_URI']
end
+ def query_string
+ @env['QUERY_STRING']
+ end
+
# returns the uri without the query string.
def path
uri ? uri.split('?').first : ''
end
@@ -76,11 +85,11 @@
host.split('.').last(1 + tld_length).join('.').sub(/:\d+$/,'')
end
# returns the REQUEST_METHOD
def method
- @method ||= @env['REQUEST_METHOD']
+ @method ||= @env['REQUEST_METHOD'].downcase.intern
end
# create predicate methods for querying the REQUEST_METHOD
[:get, :post, :put, :delete, :head].each do |m|
eval %{
@@ -90,6 +99,5 @@
end
end
-
\ No newline at end of file