Class: Explorer::Server::HTTP
- Inherits:
-
Reel::Server::HTTP
- Object
- Reel::Server::HTTP
- Explorer::Server::HTTP
- Defined in:
- lib/explorer/server/http.rb
Instance Method Summary collapse
- #handle_request(request) ⇒ Object
-
#initialize(port = 23401, map = {}) ⇒ HTTP
constructor
A new instance of HTTP.
- #on_connection(connection) ⇒ Object
Constructor Details
#initialize(port = 23401, map = {}) ⇒ HTTP
Returns a new instance of HTTP.
6 7 8 9 10 |
# File 'lib/explorer/server/http.rb', line 6 def initialize(port = 23401, map={}) @map = map super '0.0.0.0', port, {}, &method(:on_connection) end |
Instance Method Details
#handle_request(request) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/explorer/server/http.rb', line 18 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']})" end end |
#on_connection(connection) ⇒ Object
12 13 14 15 16 |
# File 'lib/explorer/server/http.rb', line 12 def on_connection(connection) connection.each_request do |request| handle_request(request) end end |