Skip to content

Commit

Permalink
Support RootUriTemplateHandler from spring-boot
Browse files Browse the repository at this point in the history
  • Loading branch information
cachescrubber committed Jan 13, 2022
1 parent 0323708 commit 1915f8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
{{! RootUriTemplateHandler }}
import org.springframework.boot.web.client.RootUriTemplateHandler;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
Expand Down Expand Up @@ -704,8 +706,16 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
//Append to finalUri the templatized query string like "?param1={param1Value}&.......
finalUri += "?" + queryUri;
}
String expandedPath = this.expandPath(finalUri, uriParams);
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath);
final UriComponentsBuilder builder;
{{! RootUriTemplateHandler }}
if (restTemplate.getUriTemplateHandler() instanceof RootUriTemplateHandler) {
builder = UriComponentsBuilder.fromPath(expandedPath);
} else {
builder = UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath);
}
URI uri;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@
<artifactId>spring-web</artifactId>
<version>${spring-web-version}</version>
</dependency>

<!-- RootUriTemplateHandler-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.6.2</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
Expand Down

0 comments on commit 1915f8b

Please sign in to comment.