Class HttpRequestResponseBodyLogUtil

java.lang.Object
org.hawaiiframework.logging.util.HttpRequestResponseBodyLogUtil

public class HttpRequestResponseBodyLogUtil extends Object
Utility for logging requests / responses.

The utility can be used to generate HTTP request / response log strings. Both for incoming service calls as outgoing calls (i.e. calls to backend systems).

Since:
2.0.0
  • Constructor Details

    • HttpRequestResponseBodyLogUtil

      public HttpRequestResponseBodyLogUtil(PasswordMaskerUtil passwordMasker)
      The constructor for the log utility.
      Parameters:
      passwordMasker - The password masker utility.
  • Method Details

    • getTxRequestBody

      public String getTxRequestBody(jakarta.servlet.http.HttpServletRequest servletRequest) throws IOException
      Get the request body. With password masking.
      Parameters:
      servletRequest - The servlet request.
      Returns:
      The body.
      Throws:
      IOException - In case the body could not be read.
    • getTxResponseBody

      public String getTxResponseBody(ContentCachingWrappedResponse servletResponse)
      Get the response body. With password masking.
      Parameters:
      servletResponse - The servlet response.
      Returns:
      The body.
    • getCallRequestBody

      public String getCallRequestBody(byte[] body)
      Get the call request body. With password masking.
      Parameters:
      body - The http request body.
      Returns:
      The body.
    • getCallResponseBody

      public String getCallResponseBody(org.springframework.http.client.ClientHttpResponse response) throws IOException
      Get the call response body. With password masking.
      Parameters:
      response - The http response.
      Returns:
      The body.
      Throws:
      IOException - in case something went wrong getting the payload from the response.