Get without id == trace since browsers dont support trace
parent
55d8cf5d43
commit
663579aeae
|
|
@ -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 {
|
func whoGet(namespace string, g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
||||||
id, err := getID(r)
|
id, err := getID(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
return whoTrace(namespace, g, w, r)
|
||||||
return json.NewEncoder(w).Encode(map[string]string{"error": err.Error()})
|
|
||||||
}
|
}
|
||||||
_, light := r.URL.Query()["light"]
|
_, light := r.URL.Query()["light"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,23 @@ func TestWho(t *testing.T) {
|
||||||
t.Logf("%+v", v)
|
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) {
|
t.Run("trace real sorted asc/desc name", func(t *testing.T) {
|
||||||
for _, order := range []string{"1", "-1"} {
|
for _, order := range []string{"1", "-1"} {
|
||||||
r := httptest.NewRequest(http.MethodTrace, "/who?namespace=col&sort=name&order="+order, nil)
|
r := httptest.NewRequest(http.MethodTrace, "/who?namespace=col&sort=name&order="+order, nil)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue