Configuring connection handlers

A connection handler is a small piece of logic that you can configure for a destination. The connection infrastructure invokes a configured connection handler before sending a request, and again when receiving the response.

Overview

Connection handlers can examine the contents of the request and response, and carry out simple processing. The following list contains examples of scenarios where a connection handler might be useful:

  • Logging requests sent to a destination and the responses received.
  • Manipulating the request or response headers.
  • Performing simple transformations of the request or response body.
  • Dynamically adding protocol configuration, such as when it cannot be statically determined by a connection configuration.

For more information about destination configuration and an overview of destination processing, see Configuring destinations. For a description of how to write a connection handler, see Creating a connection handler.

Configuring connection handlers for a destination

Specify a handlers list to configure connection handlers for a destination. Each element in the handlers list must contain a class attribute that names the connection handler implementation class. The element can also contain a config attribute in order to supply any configuration parameter required by the connection handler.

For example, the following configuration registers a single connection handler with the named destination and specifies a configuration parameter, source, for the connection handler.

/config/connection/destinations += {
    "http://www.projectzero.org/*" : {
        "handlers" : [{
            "class" : "zero.core.connection.handlers.logger.SimpleJavaLoggerHandler",
            "config" : {
                "source" : "mySourceName"
            }
        }]
    }
}

Version 1.0.0.3.25591