Class: Webmachine::Adapters::Reel
Instance Attribute Summary
#configuration, #dispatcher
Instance Method Summary
collapse
#initialize, run
Instance Method Details
#process(connection) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/webmachine/adapters/reel.rb', line 22
def process(connection)
while wreq = connection.request
= Webmachine::Headers[wreq..dup]
host_parts = .fetch('Host').split(':')
path_parts = wreq.url.split('?')
requri = URI::HTTP.build({}.tap do |h|
h[:host] = host_parts.first
h[:port] = host_parts.last.to_i if host_parts.length == 2
h[:path] = path_parts.first
h[:query] = path_parts.last if path_parts.length == 2
end)
request = Webmachine::Request.new(wreq.method.to_s.upcase,
requri,
,
LazyRequestBody.new(wreq))
response = Webmachine::Response.new
@dispatcher.dispatch(request,response)
connection.respond ::Reel::Response.new(response.code, response., response.body)
end
end
|
#run ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/webmachine/adapters/reel.rb', line 12
def run
options = {
:port => configuration.port,
:host => configuration.ip
}.merge(configuration.adapter_options)
server = ::Reel::Server.supervise(options[:host], options[:port], &method(:process))
trap("INT"){ server.terminate; exit 0 }
sleep
end
|