summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/network/http/mongrel.rb23
-rw-r--r--lib/puppet/network/http/webrick.rb22
2 files changed, 43 insertions, 2 deletions
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb
index bbba69fe3..ab1e616b1 100644
--- a/lib/puppet/network/http/mongrel.rb
+++ b/lib/puppet/network/http/mongrel.rb
@@ -6,10 +6,17 @@ class Puppet::Network::HTTP::Mongrel
end
def listen(args = {})
- raise ArgumentError, ":handlers must be specified." if !args[:handlers] or args[:handlers].keys.empty?
+ raise ArgumentError, ":handlers must be specified." if !args[:handlers] or args[:handlers].empty?
+ raise ArgumentError, ":protocols must be specified." if !args[:protocols] or args[:protocols].empty?
raise ArgumentError, ":address must be specified." unless args[:address]
raise ArgumentError, ":port must be specified." unless args[:port]
raise "Mongrel server is already listening" if listening?
+
+ @protocols = args[:protocols]
+ @handlers = args[:handlers]
+
+ setup_handlers
+
@server = Mongrel::HttpServer.new(args[:address], args[:port])
@server.run
@listening = true
@@ -24,4 +31,18 @@ class Puppet::Network::HTTP::Mongrel
def listening?
@listening
end
+
+ private
+
+ def setup_handlers
+ @protocols.each do |protocol|
+ @handlers.each do |handler|
+ class_for_protocol_handler(protocol, handler).new
+ end
+ end
+ end
+
+ def class_for_protocol_handler(protocol, handler)
+ Class.new
+ end
end
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index b74bf441e..00d13437c 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -7,11 +7,17 @@ class Puppet::Network::HTTP::WEBrick
end
def listen(args = {})
- raise ArgumentError, ":handlers must be specified." if !args[:handlers] or args[:handlers].keys.empty?
+ raise ArgumentError, ":handlers must be specified." if !args[:handlers] or args[:handlers].empty?
+ raise ArgumentError, ":protocols must be specified." if !args[:protocols] or args[:protocols].empty?
raise ArgumentError, ":address must be specified." unless args[:address]
raise ArgumentError, ":port must be specified." unless args[:port]
raise "WEBrick server is already listening" if listening?
+ @protocols = args[:protocols]
+ @handlers = args[:handlers]
+
+ setup_handlers
+
@server = WEBrick::HTTPServer.new(:BindAddress => args[:address], :Port => args[:port])
# TODO / FIXME is this really necessary? -- or can we do it in both mongrel and webrick?
@@ -30,4 +36,18 @@ class Puppet::Network::HTTP::WEBrick
def listening?
@listening
end
+
+ private
+
+ def setup_handlers
+ @handlers.each do |handler|
+ @protocols.each do |protocol|
+ class_for_protocol_handler(protocol, handler).new
+ end
+ end
+ end
+
+ def class_for_protocol_handler(protocol, handler)
+ Class.new
+ end
end