fixing pathInfo

This commit is contained in:
Francesco Mangiacrapa 2022-03-24 16:29:53 +01:00
parent 27ade09793
commit 2683d601b0
1 changed files with 7 additions and 7 deletions

View File

@ -34,15 +34,15 @@ public class UriResolverDocs {
public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { public InputStream index(@Context HttpServletRequest req) throws WebApplicationException {
logger.info(UriResolverDocs.class.getSimpleName() + " called"); logger.info(UriResolverDocs.class.getSimpleName() + " called");
String requestURI = req.getRequestURI(); String pathInfo = req.getPathInfo();
logger.info("pathInfo {}", pathInfo);
try { try {
if (requestURI == null) if (pathInfo.equals("docs"))
requestURI = "/index.html"; pathInfo += "/index.html";
String pathInfo = req.getPathInfo(); logger.info("redirecting to {}", pathInfo);
logger.info("pathInfo {}", pathInfo); logger.info("request URI {}", req.getRequestURI());
logger.info("request URI {}", requestURI);
String realPath = req.getServletContext().getRealPath(pathInfo); String realPath = req.getServletContext().getRealPath(pathInfo);
return new FileInputStream(new File(realPath)); return new FileInputStream(new File(realPath));
@ -50,7 +50,7 @@ public class UriResolverDocs {
if (!(e instanceof WebApplicationException)) { if (!(e instanceof WebApplicationException)) {
// UNEXPECTED EXCEPTION managing it as WebApplicationException // UNEXPECTED EXCEPTION managing it as WebApplicationException
String error = requestURI + " not found. Please, contact the support!"; String error = pathInfo + " not found. Please, contact the support!";
throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); throw ExceptionManager.internalErrorException(req, error, this.getClass(), null);
} }
// ALREADY MANAGED AS WebApplicationException // ALREADY MANAGED AS WebApplicationException