Parent

Innate::Request

Subclass Rack::Request and add some convenient methods.

An instance is available via the # method in your Node.

NOTE:

  Please make sure to read the documentation of Rack::Request together with
  this, as there are a lot of features available.

A list of methods from Rack::Request so you get a gist of it:

## Generally

## ENV shortcuts

## Query request method

## parameter handling

Constants

LOCAL

Public Class Methods

current() click to toggle source

Currently handled request from Thread.current[:request] Call it from anywhere via Innate::Request.current

    # File lib/innate/request.rb, line 61
61:     def self.current
62:       Current.request
63:     end

Public Instance Methods

[](value, *keys) click to toggle source

Let’s allow #[] to act like #.

Usage given a GET request like /hey?foo=duh&bar=doh

  request[:foo, :bar] # => ['duh', 'doh']

Both value and the elements of keys will be turned into String by #.

    # File lib/innate/request.rb, line 72
72:     def [](value, *keys)
73:       return super(value) if keys.empty?
74:       [value, *keys].map{|key| super(key) }
75:     end
domain(path = nil, options = {}) click to toggle source

Try to figure out the domain we are running on, this might work for some deployments but fail for others, given the combination of servers in front.

@example usage

  domain
  # => #<URI::HTTPS:0xb769ecb0 URL:https://localhost:7000/>
  domain('/foo')
  # => #<URI::HTTPS:0xb769ecb0 URL:https://localhost:7000/foo>

@param [#] path

@return [URI]

@api external @author manveru

     # File lib/innate/request.rb, line 118
118:     def domain(path = nil, options = {})
119:       uri = URI(self.url)
120:       uri.path = path.to_s if path
121:       uri.query = nil unless options[:keep_query]
122:       uri
123:     end
local_net?(address = ip) click to toggle source

Request is from a local network? Checks both IPv4 and IPv6 Answer is true if the IP address making the request is from local network. Optional argument address can be used to check any IP address.

     # File lib/innate/request.rb, line 134
134:     def local_net?(address = ip)
135:       addr = IPAddr.new(address)
136:       LOCAL.find{|range| range.include?(addr) }
137:     rescue ArgumentError => ex
138:       raise ArgumentError, ex unless ex.message == 'invalid address'
139:     end
request_uri() click to toggle source

the full request URI provided by Rack::Request e.g. “localhost:7000/controller/action?foo=bar.xhtml

    # File lib/innate/request.rb, line 79
79:     def request_uri
80:       env['REQUEST_URI'] || env['PATH_INFO']
81:     end
subset(*keys) click to toggle source

Answers with a subset of request.params with only the key/value pairs for which you pass the keys. Valid keys are objects that respond to :to_s

@example usage

  request.params
  # => {'name' => 'jason', 'age' => '45', 'job' => 'lumberjack'}
  request.subset('name')
  # => {'name' => 'jason'}
  request.subset(:name, :job)
  # => {'name' => 'jason', 'job' => 'lumberjack'}
    # File lib/innate/request.rb, line 96
96:     def subset(*keys)
97:       keys = keys.map{|key| key.to_s }
98:       params.reject{|key, value| not keys.include?(key) }
99:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.