mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 15:46:58 +08:00
api: return 500 instead of 404 in case of non-existing items (#2582)
This is needed to differentiate between calls to non-existent andpoints and calls to valid endpoints, but with an ID pointing to a non-existing item, and to return JSON in the latter case.
This commit is contained in:
@@ -398,7 +398,7 @@ func TestAPIConfigPathsDelete(t *testing.T) {
|
||||
res, err := hc.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
require.Equal(t, http.StatusInternalServerError, res.StatusCode)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ func TestAPIPathsGet(t *testing.T) {
|
||||
res, err := hc.Get("http://localhost:9997/v3/paths/get/" + pathName)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, 404, res.StatusCode)
|
||||
require.Equal(t, http.StatusInternalServerError, res.StatusCode)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1331,7 +1331,7 @@ func TestAPIProtocolGetNotFound(t *testing.T) {
|
||||
res, err := hc.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
require.Equal(t, http.StatusInternalServerError, res.StatusCode)
|
||||
}()
|
||||
})
|
||||
}
|
||||
@@ -1537,13 +1537,13 @@ func TestAPIProtocolKickNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func() {
|
||||
req, err := http.NewRequest(http.MethodGet, "http://localhost:9997/v3/"+pa+"/kick/"+uuid.New().String(), nil)
|
||||
req, err := http.NewRequest(http.MethodPost, "http://localhost:9997/v3/"+pa+"/kick/"+uuid.New().String(), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := hc.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
require.Equal(t, http.StatusInternalServerError, res.StatusCode)
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user