Class: HttpRequest
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- HttpRequest
- Defined in:
- lib/libisi/request/http.rb
Instance Attribute Summary
Attributes inherited from BaseRequest
Class Method Summary collapse
-
.from_uri(uri, options = {}) ⇒ Object
Splits a ordinary http url into * HttpEnvironment * Task(Function and Parameters).
Methods inherited from BaseRequest
Constructor Details
This class inherits a constructor from BaseRequest
Class Method Details
.from_uri(uri, options = {}) ⇒ Object
Splits a ordinary http url into
-
HttpEnvironment
-
Task(Function and Parameters)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/libisi/request/http.rb', line 32 def HttpRequest.from_uri(uri, = {}) raise "Unexpected uri provided #{uri.parse}" unless uri.class == URI::HTTP = { :root => URI::HTTP.build(:scheme => uri.scheme, :userinfo => uri.userinfo, :host => uri.host, :port => uri.port, :path => "/") }.merge() unless uri.to_s.starts_with?([:root].to_s) raise "URI #{uri.to_s} does not start with root #{[:root].to_s}" end # take the rest of the path as context, function name and arguments path_rest = uri.path[[:root].path.length..-1] # environment env = HttpEnvironment.new([:root]) # task task = HttpTask.from_path_with_parameters(path_rest + "?" + uri.query) HttpRequest.new(env, task) end |