create

fun create(vararg interceptors: Interceptor, proxier: Proxier? = null, executor: ExecutorService? = null, certificatePath: Path? = null, privateKeyPath: Path? = null, credentials: Credentials? = null): Server

Create a proxy Server instance.

The interceptors are used to dynamically transform intercepted Request and Response data. When a Request is received by the proxy Server it is associated with an Interceptor by finding the first, respective to the given order, that determines the Request to be Interceptor.interceptable. If the Request is not interceptable, then a default no-op Interceptor is used.

For the proxy Server to support proxying HTTPS requests, the certificatePath and privateKeyPath must be provided. This enables the server to decrypt the proxied requests and responses for interception, assuming the client correctly trusts the certificate at the given certificatePath.

Return

the proxy Server

Parameters

interceptors

the Array of Interceptor to use to intercept proxy requests and responses. The first Interceptor, relative to the given order, that is Interceptor.interceptable is used for each proxy request

proxier

the global Proxier to use to execute proxy requests. The global Proxier may be overridden by a specific Request through an Interceptor.proxier.

executor

the ExecutorService to use to asynchronously execute proxy requests. The asynchronous execution also includes interception of the proxy request and response.

certificatePath

the Path to the X.509 trusted certificate authority

privateKeyPath

the Path to the PKCS8 private key for the trusted certificate

credentials

the Credentials required in the proxy-authorization header

Throws

if the proxy server failed to initialize