feat(api): add debug route

This commit is contained in:
Julien Neuhart
2025-02-04 10:20:29 +01:00
parent 740e701ad3
commit a1596f7c62
22 changed files with 628 additions and 4 deletions

View File

@@ -786,6 +786,7 @@ func TestApi_Start(t *testing.T) {
mod.basicAuthUsername = "foo"
mod.basicAuthPassword = "bar"
mod.disableHealthCheckLogging = true
mod.enableDebugRoute = true
mod.routes = []Route{
{
Method: http.MethodPost,
@@ -908,6 +909,15 @@ func TestApi_Start(t *testing.T) {
t.Errorf("expected %d status code but got %d", http.StatusOK, recorder.Code)
}
// debug request.
recorder = httptest.NewRecorder()
debugRequest := httptest.NewRequest(http.MethodGet, "/debug", nil)
debugRequest.SetBasicAuth(mod.basicAuthUsername, mod.basicAuthPassword)
mod.srv.ServeHTTP(recorder, debugRequest)
if recorder.Code != http.StatusOK {
t.Errorf("expected %d status code but got %d", http.StatusOK, recorder.Code)
}
// "multipart/form-data" request.
multipartRequest := func(url string) *http.Request {
body := &bytes.Buffer{}