Merge branch 'bugfix/quick-20260119' into 'main'
fix: use Endpoints for filtered recipe urls See merge request cse1105/2025-2026/teams/csep-team-76!75
This commit is contained in:
commit
2a4b6d3fce
2 changed files with 6 additions and 6 deletions
|
|
@ -80,6 +80,10 @@ public class Endpoints {
|
||||||
return this.http(url).GET();
|
return this.http(url).GET();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HttpRequest.Builder getRecipesWith(String params) {
|
||||||
|
return this.http(this.createApiUrl("/recipes?" + params)).GET();
|
||||||
|
}
|
||||||
|
|
||||||
public HttpRequest.Builder createIngredient(HttpRequest.BodyPublisher body) {
|
public HttpRequest.Builder createIngredient(HttpRequest.BodyPublisher body) {
|
||||||
String url = this.createApiUrl("/ingredients");
|
String url = this.createApiUrl("/ingredients");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import org.glassfish.jersey.client.ClientConfig;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
|
|
@ -68,11 +67,8 @@ public class ServerUtils {
|
||||||
*/
|
*/
|
||||||
public List<Recipe> getRecipesFiltered(String filter, List<String> locales) throws IOException, InterruptedException {
|
public List<Recipe> getRecipesFiltered(String filter, List<String> locales) throws IOException, InterruptedException {
|
||||||
//TODO add limit integration
|
//TODO add limit integration
|
||||||
String uri = configService.getConfig().getServerUrl() + "/recipes?search=" + filter + "&locales=" + String.join(",", locales);
|
HttpRequest request = this.endpoints
|
||||||
HttpRequest request = HttpRequest.newBuilder()
|
.getRecipesWith("search=" + filter + "&locales=" + String.join(",", locales)).build();
|
||||||
.uri(URI.create(uri))
|
|
||||||
.GET()
|
|
||||||
.build();
|
|
||||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
|
||||||
if(response.statusCode() != statusOK){
|
if(response.statusCode() != statusOK){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue