From c4d5028f835ddcdeea5e17fed60ddb8728b0de3e Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 26 Sep 2022 12:32:08 +0200 Subject: [PATCH] Trying to fix path --- .../java/org/gcube/gcat/rest/docs/Docs.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/gcat/rest/docs/Docs.java b/src/main/java/org/gcube/gcat/rest/docs/Docs.java index 59bfa5f..5aee187 100644 --- a/src/main/java/org/gcube/gcat/rest/docs/Docs.java +++ b/src/main/java/org/gcube/gcat/rest/docs/Docs.java @@ -21,10 +21,9 @@ import org.slf4j.LoggerFactory; public class Docs { private static Logger logger = LoggerFactory.getLogger(Docs.class); - + @GET - @Path("{.*}") - public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { + public InputStream toDoc1(@Context HttpServletRequest req) throws WebApplicationException { logger.trace("Called method to redirect to docs/index.html"); String pathInfo = req.getPathInfo(); @@ -34,6 +33,25 @@ public class Docs { pathInfo += "/index.html"; } + logger.info("redirecting to {}", pathInfo); + + String realPath = req.getServletContext().getRealPath(pathInfo); + return new FileInputStream(new File(realPath)); + + } catch (Exception e) { + throw new InternalServerErrorException(e); + } + } + + + @GET + @Path("/{any: .*}") + public InputStream toDoc2(@Context HttpServletRequest req) throws WebApplicationException { + logger.trace("Called method to redirect to docs/index.html"); + + String pathInfo = req.getPathInfo(); + try { + if (pathInfo.endsWith("/docs/")) { pathInfo += "index.html"; }