Summary

This is an enhancement request to add uriTemplate parameter in the arguments of ClientHttpRequestFactory#createRequest.

Background

In RESTful principal, it is strongly recommended to include ID as a path parameter of the path of endpoint interacting with a specific resource e.g. /users/{userId}. Thus, rather than the actual path like /users/john, the URI template needs to be checked to apply endpoint specific configuration inside ClientHttpRequestFactory#createRequest using underlying client library such as timeout or logging.

Problem

Currently the method has only two arguments, URI and HttpMethod.

Due to this, my ClientHttpRequestFactory implementation needs to look up per endpoint configuration by matching URI and URI templates while the given URI is created from the endpoint's URI template.

// load endpoint configs from the property file
// Actual implemention considers http method as well but I omitted it here as it is not related here.
var endpointConfigs = Map.of(uriTemplate, endpointConf).

endpointConfigs.entrySet()
    .stream()
    .filter((template, config) -> UriTemplate.matches(template, uri))
    .first()
    .ifPresent(_, config) -> config.apply(request)).

Once uriTemplate is introduced the above code can be replaced with

var endpointConfigs = Map.of(uriTemplate, endpointConf).
endpointConfigs.get(uriTemplate).apply(request).

Comment From: quaff

It's the responsibility of RestClient, RestTemplate and WebClient to support URI template, why not use them?

Comment From: kk-mats

I already tried but those clients do not support setting timeout of each endpoint for example. What they can do is only setting default timeout for ALL API endpoints.

They do not interact undelying client library directly and just delegate request creation to ClientHttpRequestFactory so I created this issue.

Comment From: bclozel

Thanks for the proposal, but this feature is managed by UriTemplateHandler and similar in higher level HTTP clients like RestTemplate or RestClient. The ClientHttpRequestFactory is lower level and is not meant to handle URI templates.