Class: Aurora::Server::Base
- Inherits:
-
Object
- Object
- Aurora::Server::Base
- Defined in:
- lib/aurora/server/base.rb
Constant Summary collapse
- DEFAULTS =
– Constants and Attributes ++
{ :log_file => '/var/log/aurora.server.log', :log_level => Logger::ERROR }
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#options ⇒ Object
Returns the value of attribute options.
-
#processes ⇒ Object
Returns the value of attribute processes.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #authenticate(&block) ⇒ Object
-
#initialize(uri, options = {}) {|_self, @uri, @logger| ... } ⇒ Base
constructor
Starts the server listening on the port specified.
- #method_missing(name, *args, &block) ⇒ Object
-
#parse_credentials(body) ⇒ Object
– Instance Methods ++.
Constructor Details
#initialize(uri, options = {}) {|_self, @uri, @logger| ... } ⇒ Base
Starts the server listening on the port specified
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aurora/server/base.rb', line 21 def initialize(uri, = {}) # setup options @options = DEFAULTS.merge() @uri = URI.parse(uri) @logger = Logger.new(@options[:log_file]) @logger.level = @options[:log_level] @logger.info 'Starting Aurora Authentication Server...' # setup authentication handlers @logger.info 'Loading processes...' yield self, @uri, @logger @logger.info 'done.' # setup server @logger.info 'Starting HTTP Server and setting up HTTP Handler...' serv = Aurora::Server::Server.new(@uri.host, @uri.port) serv.register('/', Aurora::Server::Handler.new(self)) @logger.info 'done. Running now.' serv.run.join end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
55 56 57 |
# File 'lib/aurora/server/base.rb', line 55 def method_missing(name, *args, &block) add_process(name, block) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/aurora/server/base.rb', line 14 def logger @logger end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/aurora/server/base.rb', line 14 def @options end |
#processes ⇒ Object
Returns the value of attribute processes.
14 15 16 |
# File 'lib/aurora/server/base.rb', line 14 def processes @processes end |
#uri ⇒ Object
Returns the value of attribute uri.
14 15 16 |
# File 'lib/aurora/server/base.rb', line 14 def uri @uri end |
Instance Method Details
#authenticate(&block) ⇒ Object
51 52 53 |
# File 'lib/aurora/server/base.rb', line 51 def authenticate(&block) add_process(:authenticate, block) end |
#parse_credentials(body) ⇒ Object
– Instance Methods ++
47 48 49 |
# File 'lib/aurora/server/base.rb', line 47 def parse_credentials(body) ['mtodd', 'test'] end |