Skip to content

Commit

Permalink
Merge pull request #41 from sberlin/fix/swagger-ui-redirect
Browse files Browse the repository at this point in the history
Fix redirecting / to Swagger UI when context path has been changed
  • Loading branch information
arey authored Jan 13, 2021
2 parents 8a17aae + 36b91e4 commit 9da75e0
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -34,9 +35,12 @@
@RequestMapping("/")
public class RootRestController {

@Value("#{servletContext.contextPath}")
private String servletContextPath;

@RequestMapping(value = "/")
public void redirectToSwagger(HttpServletResponse response) throws IOException {
response.sendRedirect("/petclinic/swagger-ui.html");
response.sendRedirect(this.servletContextPath + "/swagger-ui.html");
}

}
Expand Down

0 comments on commit 9da75e0

Please sign in to comment.