12.1.1Client Interceptors


Client interceptors may be used to examine requests and responses before and after they are sent to the remote server.

12.1.2Registering Client Interceptors


Interceptors for the client are registered against individual client instances, as shown in the example below.

FhirContext ctx = FhirContext.forR4();

// Create a new client instance
IGenericClient client = ctx.newRestfulGenericClient("http://hapi.fhir.org/baseR4");

// Register an interceptor against the client
client.registerInterceptor(new LoggingInterceptor());

// Perform client actions...
Patient pt = client.read().resource(Patient.class).withId("example").execute();