From 0706b0d287fcd8e2283afc1ec283f5183a9359da Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 19 Nov 2021 13:26:47 +0000 Subject: [PATCH] Added some /site endpoints to the gateway, for backwards support of the demo sites --- .../api/gateway/resource/GatewayResource.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/org/qortal/api/gateway/resource/GatewayResource.java b/src/main/java/org/qortal/api/gateway/resource/GatewayResource.java index b3509227..74b826fd 100644 --- a/src/main/java/org/qortal/api/gateway/resource/GatewayResource.java +++ b/src/main/java/org/qortal/api/gateway/resource/GatewayResource.java @@ -41,6 +41,29 @@ public class GatewayResource { return this.get(name, ResourceIdType.NAME, Service.WEBSITE, "/", null, "", true, true); } + + // Optional /site alternative for backwards support + + @GET + @Path("/site/{name}/{path:.*}") + @SecurityRequirement(name = "apiKey") + public HttpServletResponse getSitePathByName(@PathParam("name") String name, + @PathParam("path") String inPath) { + // Block requests from localhost, to prevent websites/apps from running javascript that fetches unvetted data + Security.disallowLoopbackRequests(request); + return this.get(name, ResourceIdType.NAME, Service.WEBSITE, inPath, null, "/site", true, true); + } + + @GET + @Path("/site/{name}") + @SecurityRequirement(name = "apiKey") + public HttpServletResponse getSiteIndexByName(@PathParam("name") String name) { + // Block requests from localhost, to prevent websites/apps from running javascript that fetches unvetted data + Security.disallowLoopbackRequests(request); + return this.get(name, ResourceIdType.NAME, Service.WEBSITE, "/", null, "/site", true, true); + } + + private HttpServletResponse get(String resourceId, ResourceIdType resourceIdType, Service service, String inPath, String secret58, String prefix, boolean usePrefix, boolean async) {