Class: Nonnative::HTTPProxyServer

Inherits:
HTTPServer
  • Object
show all
Defined in:
lib/nonnative/http_proxy_server.rb

Overview

Runs HTTPProxy as a Puma-based in-process server under Nonnative.

Examples:

Nonnative.configure do |config|
  config.server do |s|
    s.name = 'github-proxy'
    s.klass = Nonnative::Features::HTTPProxyServer
    s.timeout = 2
    s.host = '127.0.0.1'
    s.ports = [4567]
    s.log = 'proxy.log'
  end
end

# In your server subclass:
# class HTTPProxyServer < Nonnative::HTTPProxyServer
#   def initialize(service)
#     super('api.github.com', service)
#   end
# end

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(host, service, scheme: 'https', port: nil) ⇒ HTTPProxyServer

Returns a new instance of HTTPProxyServer.

Parameters:

  • host (String)

    upstream host to proxy to

  • service (Nonnative::ConfigurationServer)

    server configuration

  • scheme (String) (defaults to: 'https')

    upstream scheme, "http" or "https"

  • port (Integer, nil) (defaults to: nil)

    upstream port; nil uses the scheme's default port



203
204
205
206
207
208
209
210
211
# File 'lib/nonnative/http_proxy_server.rb', line 203

def initialize(host, service, scheme: 'https', port: nil)
  http_service = Class.new(Nonnative::HTTPProxy) do
    set :host, host
    set :scheme, scheme
    set :port, port
  end

  super(http_service.new, service)
end