Refactor reverse proxy path handling and enhance documentation. Updated reverse.go to improve upstream URL construction and added a new test for nested API routes in reverse_test.go. Revised GATEWAY_RUN.md to clarify API path behavior and configuration requirements for Nginx. Adjusted comments in config.example.yaml for better understanding of HTTPS and API prefix usage.
Publish telemt-api gateway Docker image / test (push) Failing after 36s
Publish telemt-api gateway Docker image / build-and-push (push) Has been skipped

This commit is contained in:
Denozordec
2026-03-30 00:21:16 +07:00
parent 16b1d8148d
commit 5a9b402220
4 changed files with 52 additions and 28 deletions
+21
View File
@@ -45,3 +45,24 @@ func TestReverseProxyPathRewriteWithAPIBasePath(t *testing.T) {
t.Fatalf("status %d", rec.Code)
}
}
func TestReverseProxyPathNestedStatsUsers(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/api/v1/stats/users" {
t.Fatalf("path %q", r.URL.Path)
}
w.WriteHeader(http.StatusOK)
}))
defer srv.Close()
up, err := url.Parse(srv.URL + "/api/")
if err != nil {
t.Fatal(err)
}
rp := NewReverseProxy(up, "/api/gt2", "/v1", "")
req := httptest.NewRequest(http.MethodGet, "/api/gt2/stats/users", nil)
rec := httptest.NewRecorder()
rp.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status %d", rec.Code)
}
}