X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=dashboard%2Fwebapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fcontroller%2FHtml5PathsController.java;h=2385298e10f16fcde5e70d8dc5fa0f33c8e9d197;hb=refs%2Fchanges%2F80%2F2680%2F1;hp=7fb6e67428493476864b6adf95dd1ce07f8ce513;hpb=1eec0d44e5961b7ff17bf9169005e1de08fc2a74;p=nonrtric.git diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java index 7fb6e674..2385298e 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java @@ -8,9 +8,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,8 +30,7 @@ import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; /** * Listens for requests to known Angular routes. @@ -39,30 +38,29 @@ import org.springframework.web.bind.annotation.RequestMethod; @Controller public class Html5PathsController { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - /** - * Forwards the browser to the index (main) page upon request of a known route. - * This unfortunately requires duplication of the Angular route strings in the - * path mappings on this method. Could switch to a regex pattern instead someday - * if the routes change too often. - * - * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app - * - * @param request - * HttpServletRequest - * @param response - * HttpServletResponse - * @throws IOException - * On error - */ - @RequestMapping(method = { RequestMethod.OPTIONS, RequestMethod.GET }, // - path = { "/policy", "/user" }) - public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException { - URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html"); - if (logger.isDebugEnabled()) - logger.debug("forwardAngularRoutes: {} redirected to {}", request.getRequestURI(), url); - response.sendRedirect(url.toString()); - } + /** + * Forwards the browser to the index (main) page upon request of a known route. + * This unfortunately requires duplication of the Angular route strings in the + * path mappings on this method. Could switch to a regex pattern instead someday + * if the routes change too often. + * + * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app + * + * @param request + * HttpServletRequest + * @param response + * HttpServletResponse + * @throws IOException + * On error + */ + @GetMapping("/policy") + public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException { + URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html"); + if (logger.isDebugEnabled()) + logger.debug("forwardAngularRoutes: {} redirected to {}", request.getRequestURI(), url); + response.sendRedirect(url.toString()); + } }