fix: fix route path that not ends with /

This commit is contained in:
Jonas Kaninda
2024-10-28 03:26:32 +01:00
parent d9cc629a4c
commit 5e4f5f4054
3 changed files with 15 additions and 18 deletions

View File

@@ -247,30 +247,23 @@ func initConfig(configFile string) {
Routes: []Route{
{
Name: "HealthCheck",
Path: "/healthy",
Destination: "http://localhost:8080",
Rewrite: "/health",
Path: "/public",
Destination: "http://localhost:80",
Rewrite: "/healthz",
HealthCheck: "",
Cors: Cors{
Headers: map[string]string{
"Access-Control-Allow-Headers": "Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers, X-Client-Id, X-Session-Id",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Max-Age": "1728000",
},
},
},
{
Name: "Basic auth",
Path: "/basic",
Destination: "http://localhost:8080",
Rewrite: "/health",
Path: "/protected",
Destination: "https://example.com",
Rewrite: "/",
HealthCheck: "",
Blocklist: []string{},
Cors: Cors{},
Middlewares: []RouteMiddleware{
{
Path: "/basic/auth",
Rules: []string{"basic-auth", "google-jwt"},
Path: "/user",
Rules: []string{"basic-auth"},
},
},
},
@@ -285,10 +278,13 @@ func initConfig(configFile string) {
Password: "goma",
},
}, {
Name: "google-jwt",
Name: "jwt",
Type: "jwt",
Rule: JWTRuler{
URL: "https://www.googleapis.com/auth/userinfo.email",
RequiredHeaders: []string{
"Authorization",
},
Headers: map[string]string{},
Params: map[string]string{},
},

View File

@@ -107,6 +107,7 @@ func (heathRoute HealthCheckRoute) HealthCheckHandler(w http.ResponseWriter, r *
}
func (heathRoute HealthCheckRoute) HealthReadyHandler(w http.ResponseWriter, r *http.Request) {
response := HealthCheckRouteResponse{
Name: "Goma Gateway",
Status: "healthy",
Error: "",
}

View File

@@ -123,7 +123,7 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
router := r.PathPrefix(route.Path).Subrouter()
router.Use(CORSHandler(route.Cors))
router.PathPrefix("/").Handler(proxyRoute.ProxyHandler())
router.PathPrefix("").Handler(proxyRoute.ProxyHandler())
} else {
logger.Error("Error, path is empty in route %s", route.Name)
logger.Info("Route path ignored: %s", route.Path)