Method: Puppet::Network::HTTP::Rack#initialize

Defined in:
lib/vendor/puppet/network/http/rack.rb

#initialize(args) ⇒ Rack

Returns a new instance of Rack.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vendor/puppet/network/http/rack.rb', line 12

def initialize(args)
  raise ArgumentError, ":protocols must be specified." if !args[:protocols] or args[:protocols].empty?
  protocols = args[:protocols]

  # Always prepare a REST handler
  @rest_http_handler = Puppet::Network::HTTP::RackREST.new
  protocols.delete :rest

  # Prepare the XMLRPC handler, for backward compatibility (if requested)
  @xmlrpc_path = '/RPC2'
  if args[:protocols].include?(:xmlrpc)
    raise ArgumentError, "XMLRPC was requested, but no handlers were given" if !args.include?(:xmlrpc_handlers)

    @xmlrpc_http_handler = Puppet::Network::HTTP::RackXMLRPC.new(args[:xmlrpc_handlers])
    protocols.delete :xmlrpc
  end

  raise ArgumentError, "there were unknown :protocols specified." if !protocols.empty?
end