Interface ClientRequestInterceptor

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ClientRequestInterceptor
Pluggable hook for attaching headers to every outgoing FHIR request made by a TestScriptEngine run.

This is deliberately generic and knows nothing about SMART, OAuth2, or any other specific auth scheme - it is the same missing capability an HCPD sandbox integration needed a mandatory X-Request-ID header for, worked around at the time with an external proxy rather than a hook in the engine. Any consumer with a header-injection need - a bearer token obtained via fhir-frog-smart's SmartAuthProvider, a custom correlation header, or anything else - should implement this instead of reaching for another one-off proxy workaround.

Registered via TestScriptEngine.builder().requestInterceptor(...). The default is NOOP, so existing callers that never set one see no behaviour change. The interceptor is registered once on the underlying HAPI IGenericClient that is shared by every operation type (read/create/update/ delete/search/batch/transaction/history), so it applies uniformly to all of them rather than needing to be re-wired into each one.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A no-op interceptor; the default when a caller does not set one.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    intercept(ca.uhn.fhir.rest.client.api.IHttpRequest request)
    Mutate the outgoing HTTP request before it is sent - typically by adding a header such as Authorization or X-Request-ID.
  • Field Details

  • Method Details

    • intercept

      void intercept(ca.uhn.fhir.rest.client.api.IHttpRequest request)
      Mutate the outgoing HTTP request before it is sent - typically by adding a header such as Authorization or X-Request-ID.
      Parameters:
      request - the outgoing request; call IHttpRequest.addHeader(java.lang.String, java.lang.String) to attach headers