(api-service) Improved testability, always set content type to application/json

This commit is contained in:
Viktor Lofgren 2023-10-09 15:39:34 +02:00
parent 397a85eaa4
commit 6319b8ef51
4 changed files with 25 additions and 4 deletions

View File

@ -79,6 +79,8 @@ public class ApiService extends Service {
var license = licenseService.getLicense(request.params("key"));
response.type("application/json");
var cachedResponse = responseCache.getResults(license, args[0], request.queryString());
if (cachedResponse.isPresent()) {
return cachedResponse.get();
@ -90,7 +92,6 @@ public class ApiService extends Service {
// We set content type late because in the case of error, we don't want to tell the client
// that the error message is JSON when it is plain text.
response.type("application/json");
return result;
}

View File

@ -58,7 +58,7 @@ public class QueryService extends Service {
query.specs,
rsp.results,
query.searchTermsHuman,
List.of(),
List.of(), // no problems
query.domain
);
}

View File

@ -113,6 +113,7 @@ services:
ports:
- "127.0.0.1:8080:80"
- "127.0.0.1:8081:81"
- "127.0.0.1:8082:82"
volumes:
- "./run/nginx-site.conf:/etc/nginx/conf.d/default.conf"
networks:
@ -175,4 +176,4 @@ volumes:
driver_opts:
type: none
o: bind
device: run/samples
device: run/samples

View File

@ -66,4 +66,23 @@ server {
access_log off;
}
}
}
server {
listen 82;
listen [::]:82;
server_name control;
proxy_set_header X-Context $remote_addr-$connection;
proxy_set_header X-Extern-Url $scheme://$host$request_uri;
proxy_set_header X-Extern-Domain $scheme://$host;
proxy_set_header X-User-Agent $http_user_agent;
proxy_set_header X-Public "1";
location / {
proxy_pass http://api-service:5004/public/;
access_log off;
}
}