Fix /status for UDMP (#17)

This commit is contained in:
Russell Parks
2020-11-02 12:15:08 -06:00
committed by GitHub
parent abc676f62b
commit 55b1bac0bc

View File

@@ -21,6 +21,9 @@ const (
loginPath = "/api/login"
loginPathNew = "/api/auth/login"
statusPath = "/status"
statusPathNew = "/proxy/network/status"
)
type NotFoundError struct{}
@@ -47,6 +50,7 @@ type Client struct {
apiPath string
loginPath string
statusPath string
csrf string
@@ -112,12 +116,14 @@ func (c *Client) setAPIUrlStyle(ctx context.Context) error {
// the new API returns a 200 for a / request
c.apiPath = apiPathNew
c.loginPath = loginPathNew
c.statusPath = statusPathNew
return nil
}
// The old version returns a "302" (to /manage) for a / request
c.apiPath = apiPath
c.loginPath = loginPath
c.statusPath = statusPath
return nil
}
@@ -140,7 +146,8 @@ func (c *Client) Login(ctx context.Context, user, pass string) error {
UUID string `json:"uuid"`
} `json:"meta"`
}
err = c.do(ctx, "GET", "/status", nil, &status)
err = c.do(ctx, "GET", c.statusPath, nil, &status)
if err != nil {
return err
}