diff --git a/view/who.go b/view/who.go index 9427b4f..e4543fe 100644 --- a/view/who.go +++ b/view/who.go @@ -44,8 +44,7 @@ func who(g storage.Graph, w http.ResponseWriter, r *http.Request) error { func whoGet(namespace string, g storage.Graph, w http.ResponseWriter, r *http.Request) error { id, err := getID(r) if err != nil { - w.WriteHeader(http.StatusBadRequest) - return json.NewEncoder(w).Encode(map[string]string{"error": err.Error()}) + return whoTrace(namespace, g, w, r) } _, light := r.URL.Query()["light"] diff --git a/view/who_test.go b/view/who_test.go index 0050908..ba1b344 100644 --- a/view/who_test.go +++ b/view/who_test.go @@ -254,6 +254,23 @@ func TestWho(t *testing.T) { t.Logf("%+v", v) }) + t.Run("get without id == trace real", func(t *testing.T) { + r := httptest.NewRequest(http.MethodGet, "/who?namespace=col", nil) + w := httptest.NewRecorder() + handler.ServeHTTP(w, r) + if w.Code != http.StatusOK { + t.Fatalf("%d: %s", w.Code, w.Body.Bytes()) + } + var v []string + if err := json.Unmarshal(w.Body.Bytes(), &v); err != nil { + t.Fatalf("%v: %s", err, w.Body.Bytes()) + } + if len(v) < 5 { + t.Fatal(len(v)) + } + t.Logf("%+v", v) + }) + t.Run("trace real sorted asc/desc name", func(t *testing.T) { for _, order := range []string{"1", "-1"} { r := httptest.NewRequest(http.MethodTrace, "/who?namespace=col&sort=name&order="+order, nil)