Class: PuppetX::Puppetlabs::CD4PEApi::JRubyHandler

Inherits:
Object
  • Object
show all
Includes:
Puppet::Server::Network::HTTP::Handler, Singleton
Defined in:
lib/puppet_x/puppetlabs/cd4pe_api/jruby_handler.rb

Overview

Hooks up the route between jruby and puppet

Instance Method Summary collapse

Constructor Details

#initializeJRubyHandler

Returns a new instance of JRubyHandler.



16
17
18
19
20
21
22
23
# File 'lib/puppet_x/puppetlabs/cd4pe_api/jruby_handler.rb', line 16

def initialize
  route_path = %r{^#{Puppet::Network::HTTP::MASTER_URL_PREFIX}/v3/cd4pe/compile/[^/]+$}

  diff_handler = Puppet::Network::HTTP::Route.path(route_path)
                                             .get(PuppetX::Puppetlabs::CD4PEApi::CompileHandler.new)

  register([diff_handler])
end

Instance Method Details

#handle(request) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/puppet_x/puppetlabs/cd4pe_api/jruby_handler.rb', line 25

def handle(request)
  response = {}
  process(request, response)

  com.puppetlabs.puppetserver.JRubyPuppetResponse.new(
    response[:status],
    response[:body],
    response[:content_type],
    response['X-Puppet-Version'],
  )
end