Tidy up the REST interface URLs (fixes #1593)
This commit is contained in:
@@ -18,18 +18,27 @@ import (
|
||||
)
|
||||
|
||||
var jsonEndpoints = []string{
|
||||
"/rest/completion?device=I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU&folder=default",
|
||||
"/rest/config",
|
||||
"/rest/config/sync",
|
||||
"/rest/connections",
|
||||
"/rest/errors",
|
||||
"/rest/events",
|
||||
"/rest/lang",
|
||||
"/rest/model?folder=default",
|
||||
"/rest/need",
|
||||
"/rest/deviceid?id=I6KAH7666SLLLB5PFXSOAUFJCDZCYAOMLEKCP2GB32BV5RQST3PSROAU",
|
||||
"/rest/report",
|
||||
"/rest/system",
|
||||
"/rest/db/completion?device=I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU&folder=default",
|
||||
"/rest/db/ignores?folder=default",
|
||||
"/rest/db/need?folder=default",
|
||||
"/rest/db/status?folder=default",
|
||||
"/rest/db/browse?folder=default",
|
||||
"/rest/events?since=-1&limit=5",
|
||||
"/rest/stats/device",
|
||||
"/rest/stats/folder",
|
||||
"/rest/svc/deviceid?id=I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU",
|
||||
"/rest/svc/lang",
|
||||
"/rest/svc/report",
|
||||
"/rest/system/browse?current=.",
|
||||
"/rest/system/config",
|
||||
"/rest/system/config/insync",
|
||||
"/rest/system/connections",
|
||||
"/rest/system/discovery",
|
||||
"/rest/system/error",
|
||||
"/rest/system/ping",
|
||||
"/rest/system/status",
|
||||
"/rest/system/upgrade",
|
||||
"/rest/system/version",
|
||||
}
|
||||
|
||||
func TestGetIndex(t *testing.T) {
|
||||
@@ -194,7 +203,7 @@ func TestPOSTWithoutCSRF(t *testing.T) {
|
||||
|
||||
// Should fail without CSRF
|
||||
|
||||
req, err := http.NewRequest("POST", "http://127.0.0.1:8082/rest/error/clear", nil)
|
||||
req, err := http.NewRequest("POST", "http://127.0.0.1:8082/rest/system/error/clear", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -241,7 +250,7 @@ func TestPOSTWithoutCSRF(t *testing.T) {
|
||||
|
||||
// Should fail with incorrect CSRF
|
||||
|
||||
req, err = http.NewRequest("POST", "http://127.0.0.1:8082/rest/error/clear", nil)
|
||||
req, err = http.NewRequest("POST", "http://127.0.0.1:8082/rest/system/error/clear", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestManyPeers(t *testing.T) {
|
||||
}
|
||||
defer receiver.stop()
|
||||
|
||||
resp, err := receiver.get("/rest/config")
|
||||
resp, err := receiver.get("/rest/system/config")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func TestManyPeers(t *testing.T) {
|
||||
|
||||
var buf bytes.Buffer
|
||||
json.NewEncoder(&buf).Encode(cfg)
|
||||
resp, err = receiver.post("/rest/config", &buf)
|
||||
resp, err = receiver.post("/rest/system/config", &buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (p *syncthingProcess) start() error {
|
||||
for {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
|
||||
resp, err := p.get("/rest/system")
|
||||
resp, err := p.get("/rest/system/status")
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -89,14 +89,14 @@ func (p *syncthingProcess) start() error {
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
// This one is unexpected. Print it.
|
||||
log.Println("/rest/system (JSON):", err)
|
||||
log.Println("/rest/system/status (JSON):", err)
|
||||
continue
|
||||
}
|
||||
|
||||
id, err := protocol.DeviceIDFromString(sysData["myID"].(string))
|
||||
if err != nil {
|
||||
// This one is unexpected. Print it.
|
||||
log.Println("/rest/system (myID):", err)
|
||||
log.Println("/rest/system/status (myID):", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ type model struct {
|
||||
}
|
||||
|
||||
func (p *syncthingProcess) model(folder string) (model, error) {
|
||||
resp, err := p.get("/rest/model?folder=" + folder)
|
||||
resp, err := p.get("/rest/db/status?folder=" + folder)
|
||||
if err != nil {
|
||||
return model{}, err
|
||||
}
|
||||
@@ -283,7 +283,7 @@ type versionResp struct {
|
||||
}
|
||||
|
||||
func (p *syncthingProcess) version() (string, error) {
|
||||
resp, err := p.get("/rest/version")
|
||||
resp, err := p.get("/rest/system/version")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func (p *syncthingProcess) version() (string, error) {
|
||||
}
|
||||
|
||||
func (p *syncthingProcess) rescan(folder string) error {
|
||||
resp, err := p.post("/rest/scan?folder="+folder, nil)
|
||||
resp, err := p.post("/rest/db/scan?folder="+folder, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func (p *syncthingProcess) rescan(folder string) error {
|
||||
}
|
||||
|
||||
func (p *syncthingProcess) reset(folder string) error {
|
||||
resp, err := p.post("/rest/reset?folder="+folder, nil)
|
||||
resp, err := p.post("/rest/system/reset?folder="+folder, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user