public interface HttpInterceptorIFC
Integration Server provides a framework for creating and registering an HTTP interceptor. An HTTP interceptor intercepts all received HTTP requests and outbound HTTP responses. Integration Server makes the raw HTTP request and response, including the HTTP header information, accessible to the HTTP interceptor. In the case of HTTP requests, the HTTP interceptor intercepts a received HTTP request before Integration server performs any processing. For an outbound HTTP response, the HTTP interceptor intercepts an HTTP response after Integration Server creates the HTTP response but before Integration Server sends the response to the requesting client.
An HTTP interceptor is comprised of:
An HTTP interceptor can be useful if there is some logic, such as an auditing requirement, that you want executed for every request and response. By placing the logic in in the interceptor, you ensure that Integration Server executes the logic for every HTTP request and response. For example, you can use an HTTP interceptor to write all HTTP requests and responses to a data lake or perform some kind of logging.
Keep the following information in mind when creating an HTTP interceptor:
Following are the general steps to take when creating an HTTP interceptor.
Modifier and Type | Method and Description |
---|---|
void |
postProcess(int responseCode,
java.lang.String responseMessage,
java.util.Map<java.lang.String,java.lang.String> headers,
byte[] bytes,
java.lang.String correlationID)
Receives HTTP Response data after all processing has been done, but before the response
is sent back to the client.
|
void |
preProcess(java.lang.String requestURL,
java.lang.String requestType,
java.lang.String httpVersion,
java.util.Map headers,
byte[] streamBytes,
java.lang.String correlationID)
Receives HTTP request data before any processing has been done on the Integration Server.
|
void preProcess(java.lang.String requestURL, java.lang.String requestType, java.lang.String httpVersion, java.util.Map headers, byte[] streamBytes, java.lang.String correlationID) throws HttpInterceptorException
requestURL
- The URL used by the client for this HTTP request, including the query if present.requestType
- The HTTP method used. Possible values are GET, PUT, POST, PATCH, and DELETE.httpVersion
- The HTTP version of the request.headers
- A map of the fields in the request transport header, where key names represent header
field names and values represent the header field values.streamBytes
- The body of the HTTP request represented as a byte array.correlationID
- An id assigned to this request that can be used to correlate this request to a specific
response when it comes back through the HTTP Interceptor.HttpInterceptorException
- - Thrown by preProcess method to interrupt Integration Server processing of this request.void postProcess(int responseCode, java.lang.String responseMessage, java.util.Map<java.lang.String,java.lang.String> headers, byte[] bytes, java.lang.String correlationID)
responseCode
- HTTP status code of the response.responseMessage
- HTTP status message of the response.headers
- A map of the fields in the response transport header, where key names represent header
field names and values represent the header field values.bytes
- The body of the HTTP response represented as a byte array.correlationID
- An id assigned to the original preprocess request that can be used to correlate this
postProcess response back to a specific request that came through the HTTP Interceptor.