Class: Puppet::Network::HTTP::API::Server::V3

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/network/http/api/server/v3.rb,
lib/puppet/network/http/api/server/v3/environments.rb

Defined Under Namespace

Classes: Environments

Constant Summary collapse

INDIRECTED =
Puppet::Network::HTTP::Route
.path(/.*/)
.any(wrap { Puppet::Network::HTTP::API::IndirectedRoutes.new })
ENVIRONMENTS =
Puppet::Network::HTTP::Route
.path(%r{^/environments$})
.get(wrap { Environments.new(Puppet.lookup(:environments)) })

Class Method Summary collapse

Class Method Details

.routesObject



30
31
32
33
34
# File 'lib/puppet/network/http/api/server/v3.rb', line 30

def self.routes
  Puppet::Network::HTTP::Route.path(/v3/)
                              .any
                              .chain(ENVIRONMENTS, INDIRECTED)
end

.wrap(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/puppet/network/http/api/server/v3.rb', line 12

def self.wrap(&block)
  lambda do |request, response|
    Puppet::Network::Authorization
      .check_external_authorization(request.method,
                                    request.path)

    block.call.call(request, response)
  end
end