Class: Explorer::Server::HTTPS
- Inherits:
-
Reel::Server::HTTPS
- Object
- Reel::Server::HTTPS
- Explorer::Server::HTTPS
- Defined in:
- lib/explorer/server/https.rb
Instance Method Summary collapse
- #handle_request(request) ⇒ Object
-
#initialize(port = 23402, map = {}) ⇒ HTTPS
constructor
A new instance of HTTPS.
- #on_connection(connection) ⇒ Object
Constructor Details
#initialize(port = 23402, map = {}) ⇒ HTTPS
Returns a new instance of HTTPS.
6 7 8 9 10 11 12 13 14 |
# File 'lib/explorer/server/https.rb', line 6 def initialize(port = 23402, map={}) @map = map = { cert: File.read(File.join(Explorer::DATADIR, 'server.crt')), key: File.read(File.join(Explorer::DATADIR, 'server.key')) } super '0.0.0.0', port, , &method(:on_connection) end |
Instance Method Details
#handle_request(request) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/explorer/server/https.rb', line 22 def handle_request(request) map = @map[request.headers['Host']] if map Proxy.new(map[:host], map[:port]).handle(request) else request.respond 404, "Map not found (#{request.headers['Host']}) (#{@map.inspect})" end end |
#on_connection(connection) ⇒ Object
16 17 18 19 20 |
# File 'lib/explorer/server/https.rb', line 16 def on_connection(connection) connection.each_request do |request| handle_request(request) end end |