allow controlling New externally
This commit is contained in:
parent
bee5bd5f92
commit
e1583f0d89
|
|
@ -36,7 +36,7 @@ const (
|
||||||
// path returns the correct api path based on the new variable.
|
// path returns the correct api path based on the new variable.
|
||||||
// new is based on the unifi-controller output. is it new or old output?
|
// new is based on the unifi-controller output. is it new or old output?
|
||||||
func (u *Unifi) path(path string) string {
|
func (u *Unifi) path(path string) string {
|
||||||
if u.isNew {
|
if u.New {
|
||||||
if path == APILoginPath {
|
if path == APILoginPath {
|
||||||
return APILoginPathNew
|
return APILoginPathNew
|
||||||
}
|
}
|
||||||
|
|
@ -76,6 +76,7 @@ type Config struct {
|
||||||
VerifySSL bool
|
VerifySSL bool
|
||||||
ErrorLog Logger
|
ErrorLog Logger
|
||||||
DebugLog Logger
|
DebugLog Logger
|
||||||
|
New bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unifi is what you get in return for providing a password! Unifi represents
|
// Unifi is what you get in return for providing a password! Unifi represents
|
||||||
|
|
@ -86,8 +87,7 @@ type Unifi struct {
|
||||||
*http.Client
|
*http.Client
|
||||||
*Config
|
*Config
|
||||||
*server
|
*server
|
||||||
isNew bool
|
csrf string
|
||||||
csrf string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// server is the /status endpoint from the Unifi controller.
|
// server is the /status endpoint from the Unifi controller.
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ func (u *Unifi) checkNewStyleAPI() error {
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusOK {
|
if resp.StatusCode == http.StatusOK {
|
||||||
// The new version returns a "200" for a / request.
|
// The new version returns a "200" for a / request.
|
||||||
u.isNew = true
|
u.New = true
|
||||||
u.DebugLog("Using NEW UniFi controller API paths for %s", req.URL)
|
u.DebugLog("Using NEW UniFi controller API paths for %s", req.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue