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.
|
||||
// new is based on the unifi-controller output. is it new or old output?
|
||||
func (u *Unifi) path(path string) string {
|
||||
if u.isNew {
|
||||
if u.New {
|
||||
if path == APILoginPath {
|
||||
return APILoginPathNew
|
||||
}
|
||||
|
|
@ -76,6 +76,7 @@ type Config struct {
|
|||
VerifySSL bool
|
||||
ErrorLog Logger
|
||||
DebugLog Logger
|
||||
New bool
|
||||
}
|
||||
|
||||
// Unifi is what you get in return for providing a password! Unifi represents
|
||||
|
|
@ -86,8 +87,7 @@ type Unifi struct {
|
|||
*http.Client
|
||||
*Config
|
||||
*server
|
||||
isNew bool
|
||||
csrf string
|
||||
csrf string
|
||||
}
|
||||
|
||||
// server is the /status endpoint from the Unifi controller.
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func (u *Unifi) checkNewStyleAPI() error {
|
|||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue