Sha256: b954bb5be5c8d9495326632da0540af2103e3793196dbeb5354b8b1f70980ac0

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 Bytes

Contents

require 'puppet/network/http/handler'

class Puppet::Network::HTTP::MongrelREST < Puppet::Network::HTTP::Handler

  private
    
    def register_handler
        @server.register('/' + @handler.to_s, self)
        @server.register('/' + @handler.to_s + 's', self)
    end
    
    def http_method(request)
        request.params[Mongrel::Const::REQUEST_METHOD]
    end
    
    def path(request)
        '/' + request.params[Mongrel::Const::REQUEST_PATH].split('/')[1]
    end
    
    def request_key(request)
        request.params[Mongrel::Const::REQUEST_PATH].split('/')[2]        
    end
    
    def body(request)
        request.body
    end
    
    def params(request)
        Mongrel::HttpRequest.query_parse(request.params["QUERY_STRING"])
    end
    
    def encode_result(request, response, result, status = 200)
        response.start(status) do |head, body|
            body.write(result)
        end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-0.24.0 lib/puppet/network/http/mongrel/rest.rb
puppet-0.24.2 lib/puppet/network/http/mongrel/rest.rb
puppet-0.24.1 lib/puppet/network/http/mongrel/rest.rb
puppet-0.24.3 lib/puppet/network/http/mongrel/rest.rb