Class: Rubapi::Server

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::HttpServer
Defined in:
lib/rubapi/server.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.rest_routesObject

Returns the value of attribute rest_routes.



6
7
8
# File 'lib/rubapi/server.rb', line 6

def rest_routes
  @rest_routes
end

Class Method Details

.route_with(routes) ⇒ Object



8
9
10
# File 'lib/rubapi/server.rb', line 8

def route_with(routes)
  self.rest_routes = routes
end

Instance Method Details

#build_paramsObject



13
14
15
16
17
18
# File 'lib/rubapi/server.rb', line 13

def build_params
  Request.new.tap do |r|
    r.parse(@http_query_string)
    r.parse(@http_post_content)
  end
end

#process_http_requestObject



20
21
22
23
24
25
# File 'lib/rubapi/server.rb', line 20

def process_http_request

  controller = Controller.new(EM::DelegatedHttpResponse.new(self))
  controller.request = build_params 
  controller.run Server.rest_routes.fetch(@http_request_uri, @http_request_method.downcase.to_sym)
end