Class HttpPath


  • public class HttpPath
    extends Object
    Specifies the path for an HTTP request.

    May also include the query string, if desired.

    Create new instances using the static factory method.

    See Also:
    of(String, String...)
    • Method Detail

      • of

        public static HttpPath of​(String template,
                                  String... args)
        Returns a new path, substituting any "{}" placeholders in the template with the corresponding argument.

        Placeholder values are automatically URL-encoded.

        Example usage:

         HttpPath path = HttpPath.of("/foo/{}/bar/{}", "hello world", "xyzzy");
         System.out.println(path);
         
        Output:
         /foo/hello%20world/bar/xyzzy
         
        Parameters:
        template - The template string, which may include "{}" placeholders.
        args - un-encoded values to substitute for the placeholders. Values are automatically URL-encoded during the substitution process.
        Throws:
        IllegalArgumentException - if the number of placeholders does not match the number of arguments.
        See Also:
        of(String, List)