Add Pi-hole blocked percentage and date widgets
This commit is contained in:
+10
-1
@@ -41,6 +41,9 @@ func (ph *PiHConnector) post(endpoint string, body io.Reader) []byte {
|
||||
}
|
||||
|
||||
func (ph *PiHConnector) do(method string, endpoint string, body io.Reader) []byte {
|
||||
if ph.Host == "" {
|
||||
return make([]byte, 0)
|
||||
}
|
||||
var requestString = "http://" + ph.Host + "/api/" + endpoint
|
||||
|
||||
client := &http.Client{}
|
||||
@@ -67,7 +70,12 @@ func (ph *PiHConnector) do(method string, endpoint string, body io.Reader) []byt
|
||||
return respBody
|
||||
}
|
||||
|
||||
var connector *PiHConnector
|
||||
|
||||
func Connect() PiHConnector {
|
||||
if connector != nil {
|
||||
return *connector
|
||||
}
|
||||
cfg := &configFile{}
|
||||
config.LoadConfig(cfg)
|
||||
client := &http.Client{}
|
||||
@@ -93,8 +101,9 @@ func Connect() PiHConnector {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return PiHConnector{
|
||||
connector = &PiHConnector{
|
||||
Host: cfg.Pihole.Host,
|
||||
Session: s.Session,
|
||||
}
|
||||
return *connector
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user