Improve query params in uri KeyValue with HTTP interface client
Prior to this commit, the HTTP interface client would create URI
templates and name query params like so:
"?{queryParam0}={queryParam0[0]}".
While technically correct, the URI template is further used in
observations as a KeyValue. This means that several service methods
could result in having the exact same URI template even if they produce
a different set of query params.
This commit improves the naming of query params in the generated URI
templates for better observability integration.
Closes gh-34176
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -492,16 +492,14 @@ public class HttpRequestValues {
|
||||
String uriTemplate, Map<String, String> uriVars, MultiValueMap<String, String> requestParams) {
|
||||
|
||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(uriTemplate);
|
||||
int i = 0;
|
||||
for (Map.Entry<String, List<String>> entry : requestParams.entrySet()) {
|
||||
String nameVar = "queryParam" + i;
|
||||
String nameVar = entry.getKey();
|
||||
uriVars.put(nameVar, entry.getKey());
|
||||
for (int j = 0; j < entry.getValue().size(); j++) {
|
||||
String valueVar = nameVar + "[" + j + "]";
|
||||
uriVars.put(valueVar, entry.getValue().get(j));
|
||||
uriComponentsBuilder.queryParam("{" + nameVar + "}", "{" + valueVar + "}");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return uriComponentsBuilder.build().toUriString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user