Class PathParamInterceptor

  • All Implemented Interfaces:
    okhttp3.Interceptor

    public class PathParamInterceptor
    extends java.lang.Object
    implements okhttp3.Interceptor
    OkHttp Interceptor implementation that substitutes path parameters in URL segments.

    This interceptor replaces token strings in the URL path segments with specified values. A path parameter is identified by the format {paramName}, where 'paramName' is the name of the parameter to be substituted.

    Example: For a URL like "https://example.com/api/{projectName}/launch" When configured with PathParamInterceptor("projectName", "testProject") The resulting URL will be "https://example.com/api/testProject/launch"

    This interceptor is used in the ReportPortal client to replace project name placeholders in API endpoints with the actual project name specified in the client configuration.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface okhttp3.Interceptor

        okhttp3.Interceptor.Chain, okhttp3.Interceptor.Companion
    • Field Summary

      • Fields inherited from interface okhttp3.Interceptor

        Companion
    • Constructor Summary

      Constructors 
      Constructor Description
      PathParamInterceptor​(java.lang.String replaceKey, java.lang.String replaceValue)
      Constructs a PathParamInterceptor with specified parameter name and replacement value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      okhttp3.Response intercept​(okhttp3.Interceptor.Chain chain)
      Intercepts the HTTP request and replaces any path segments containing the specified parameter with the replacement value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PathParamInterceptor

        public PathParamInterceptor​(java.lang.String replaceKey,
                                    java.lang.String replaceValue)
        Constructs a PathParamInterceptor with specified parameter name and replacement value.
        Parameters:
        replaceKey - The name of the parameter to replace (will be wrapped in {} in the URL)
        replaceValue - The value to substitute for the parameter
    • Method Detail

      • intercept

        @Nonnull
        public okhttp3.Response intercept​(okhttp3.Interceptor.Chain chain)
                                   throws java.io.IOException
        Intercepts the HTTP request and replaces any path segments containing the specified parameter with the replacement value.
        Specified by:
        intercept in interface okhttp3.Interceptor
        Parameters:
        chain - The interceptor chain
        Returns:
        The response from the chain after processing the modified request
        Throws:
        java.io.IOException - If an I/O error occurs during request processing