summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-15 15:29:00 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-15 15:29:00 -0500
commitba952029b057cb64cf28d9e4dfb5c78868a4b53f (patch)
tree2e7841459707683a967dcb5c51e445eaea0cd172 /lib
parentef8ebe0df4da0a0cd2f599308f40bd707ab18d92 (diff)
downloadpuppet-ba952029b057cb64cf28d9e4dfb5c78868a4b53f.tar.gz
puppet-ba952029b057cb64cf28d9e4dfb5c78868a4b53f.tar.xz
puppet-ba952029b057cb64cf28d9e4dfb5c78868a4b53f.zip
Partial support for building Handlers for all handler-protocol pairs.
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