Spike concepts

Proxy basics

Spike is a proxy server. It intercepts HTTP requests, passes the request to some server's endpoint, then intercepts the server response before returning it to the original caller.

Spike can run as either a forward (or outbound) proxy, or as a reverse (inbound) proxy. To use as a forward proxy, you must first configure your client application or service (making requests to Spike) to use an http proxy (instructions here). Proxy mode is supported by most HTTP client libraries.

To use Spike instead as a reverse proxy, create a port-only service (see instructions here), along with an endpoint for that service, pointing at the destination server (which can be on a remote machine, or on locahost at a different port number).

Services and Endpoints

  • A Service is a single API call on a server, which can be invoked by a client. For example, a call to request product information, or customer status. Note that the word service is sometimes used by people to refer to a collection of related APIs, but for simplicity, in Spike it means a single API method.

    A Service contains an address, which is used to match incoming requests. The address must be unique across all defined Services. An incoming request matches a particular service if the following three conditions hold:

    • The scheme (http or https) of the incoming request matches the scheme of the service's address,
    • The host and post (e.g., foobar.com:8881) of the incoming request matches the host and port of the service's address,
    • The address's path (e.g., /api/v1/getusers) is a prefix of the incoming request's path.
    Note that the query string of the incoming request is not used during matching. A service's address should not contain a query string, for that reason.

  • An Endpoint is the actual destination URL of a service. A service may have several endpoints, corresponding to different versions (e.g., dev/QA/stage/prod, different versions in production, etc).

    If you create a service and don't define any endpoints, then the service will be treated as a simple pass-through. That is, any incoming request which matches the service's address (as outlined above) will be transparently passed through to the request URL without any modification.

    Furthermore, if a service has a single endpoint defined and the URL of the endpoint is the same as the address of the service, then this also becomes a pass-through.