fix(client/util): replaced hardcoded values with configService-based impl
This commit is contained in:
parent
c214eff502
commit
5d199e9a33
3 changed files with 8 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package client.utils.server;
|
||||
|
||||
import client.utils.ConfigService;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.inject.Inject;
|
||||
|
|
@ -13,6 +14,7 @@ import org.glassfish.jersey.client.ClientConfig;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
|
|
@ -27,14 +29,16 @@ public class ServerUtils {
|
|||
private Logger logger = Logger.getLogger(ServerUtils.class.getName());
|
||||
private final HttpClient client;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private final ConfigService configService;
|
||||
private final int statusOK = 200;
|
||||
|
||||
private final Endpoints endpoints;
|
||||
|
||||
@Inject
|
||||
public ServerUtils(HttpClient client, Endpoints endpoints) {
|
||||
public ServerUtils(HttpClient client, Endpoints endpoints, ConfigService configService) {
|
||||
this.client = client;
|
||||
this.endpoints = endpoints;
|
||||
this.configService = configService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +68,7 @@ public class ServerUtils {
|
|||
*/
|
||||
public List<Recipe> getRecipesFiltered(String filter, List<String> locales) throws IOException, InterruptedException {
|
||||
//TODO add limit integration
|
||||
String uri = SERVER + "/recipes?search=" + filter + "&locales=" + String.join(",", locales);
|
||||
String uri = configService.getConfig().getServerUrl() + "/recipes?search=" + filter + "&locales=" + String.join(",", locales);
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create(uri))
|
||||
.GET()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue