Skip to content

Commit

Permalink
Oppdatert URI II #deploy-tenor-search-service
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum committed Jan 12, 2024
1 parent fa9dbd6 commit 251f768
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public TenorClient(Consumers consumers, MaskinportenClient maskinportenClient) {
public Mono<TenorResponse> getTestdata(String query) {

return maskinportenClient.getAccessToken()
.flatMap(token -> new GetTenorTestdata(webClient,
query.replace("{", "%7b")
.replace("}", "%7d"),
token.value()).call());
.flatMap(token -> new GetTenorTestdata(webClient, query, token.value()).call());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import no.nav.testnav.apps.tenorsearchservice.domain.TenorResponse;
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
Expand All @@ -13,28 +12,29 @@
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

import java.net.URI;
import java.time.Duration;
import java.util.concurrent.Callable;

@Slf4j
@RequiredArgsConstructor
public class GetTenorTestdata implements Callable<Mono<TenorResponse>> {

private static final String TENOR_QUERY_URL = "/api/testnorge/v2/soek/freg?kql=";
private static final String TENOR_QUERY_URL = "/api/testnorge/v2/soek/freg";

private final WebClient webClient;
private final String query;
private final String token;

@Override
@SneakyThrows
public Mono<TenorResponse> call() {

log.info("Query-parameter: {}", query);

return webClient.get()
.uri(new URI(TENOR_QUERY_URL+query+"nokkelinformasjon:true"))
.uri(uriBuilder -> uriBuilder.path(TENOR_QUERY_URL)
.queryParam("kql", query)
.queryParam("nokkelinformasjon", true)
.build())
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
Expand Down

0 comments on commit 251f768

Please sign in to comment.