Class: Aurora::Server::Handler
- Inherits:
-
Mongrel::HttpHandler
- Object
- Mongrel::HttpHandler
- Aurora::Server::Handler
- Defined in:
- lib/aurora/server/handler.rb
Instance Attribute Summary collapse
-
#serv ⇒ Object
– constants and attributes ++.
Instance Method Summary collapse
-
#initialize(serv) ⇒ Handler
constructor
Stores a reference to the Base server to access the processes (procs which define auth functionality) and then returns to the super.
-
#process(request, response) ⇒ Object
Generic request processor (Mongrel hook).
Constructor Details
#initialize(serv) ⇒ Handler
Stores a reference to the Base server to access the processes (procs which define auth functionality) and then returns to the super
17 18 19 20 21 |
# File 'lib/aurora/server/handler.rb', line 17 def initialize(serv) @serv = serv @serv.logger.info 'Loading Handler.' super() end |
Instance Attribute Details
#serv ⇒ Object
– constants and attributes ++
9 10 11 |
# File 'lib/aurora/server/handler.rb', line 9 def serv @serv end |
Instance Method Details
#process(request, response) ⇒ Object
Generic request processor (Mongrel hook)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/aurora/server/handler.rb', line 28 def process(request, response) @serv.logger.info 'Request received.' # parse out username and password and call the authenticate method @serv.logger.info request.body user, pass = *Aurora::Server::Base.parse_credentials(request.body) response = @serv.processses[:authenticate].call(user, pass) # prepare response if response.is_a? Aurora::Server::Token then # success code = 200 else # failure code = 200 end # send response response.start(code) do |head, out| head["Content-Type"] = "application/json" out.write(result.to_json) end end |