Adding a new HomeController to redirect to swagger UI
This commit is contained in:
parent
77a43bfde8
commit
4016854514
@ -0,0 +1,32 @@
|
||||
package com.hithomelabs.CFTunnels.Controllers;
|
||||
|
||||
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class HomeController implements ErrorController {
|
||||
|
||||
private static final String ERROR_PATH = "/error";
|
||||
|
||||
/**
|
||||
* Redirects the root (including any query params like ?continue=…)
|
||||
* straight into Swagger UI.
|
||||
*/
|
||||
@GetMapping("/")
|
||||
public String rootRedirect() {
|
||||
return "redirect:/swagger-ui/index.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* Catches any errors (404s, unhandled paths) and punts them
|
||||
* into the same Swagger UI page.
|
||||
*/
|
||||
@RequestMapping(ERROR_PATH)
|
||||
public String onError() {
|
||||
return "redirect:/swagger-ui/index.html";
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,6 +9,7 @@ import com.hithomelabs.CFTunnels.Models.Config;
|
||||
import com.hithomelabs.CFTunnels.Models.Ingress;
|
||||
import com.hithomelabs.CFTunnels.Models.TunnelResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@ -23,9 +24,10 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cloudflare")
|
||||
public class TunnelController {
|
||||
public class TunnelController implements ErrorController {
|
||||
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
private static final String ERROR_PATH = "/error";
|
||||
|
||||
@Autowired
|
||||
private AuthoritiesToGroupMapping authoritiesToGroupMapping;
|
||||
@ -38,11 +40,6 @@ public class TunnelController {
|
||||
@Autowired
|
||||
private RestTemplateConfig restTemplateConfig;
|
||||
|
||||
@GetMapping("/")
|
||||
public String redirectToSwagger() {
|
||||
return "redirect:/swagger-ui/index.html";
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('USER')")
|
||||
@GetMapping("/whoami")
|
||||
public Map<String,Object> whoAmI(@AuthenticationPrincipal OidcUser oidcUser) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user