1
0
mirror of https://github.com/IceWhaleTech/CasaOS.git synced 2025-07-06 23:37:26 +02:00
Files
CasaOS/pkg/zerotier/zerotier_api.go

48 lines
952 B
Go
Raw Normal View History

2021-09-26 10:35:02 +08:00
package zerotier
import (
2021-09-27 14:17:36 +08:00
httper2 "github.com/IceWhaleTech/CasaOS/pkg/utils/httper"
2021-09-26 10:35:02 +08:00
"github.com/tidwall/gjson"
"net/http"
)
2021-09-27 14:17:36 +08:00
func PostData(url, token string, data string) interface{} {
2021-09-26 10:35:02 +08:00
body, code := httper2.ZeroTierPostJson(url, data, GetHead(token))
if code != http.StatusOK {
return ""
}
result := gjson.Parse(body)
return result.Value()
}
func GetData(url, token string) interface{} {
body, code := httper2.ZeroTierGet(url, GetHead(token))
if code != http.StatusOK {
return ""
}
result := gjson.Parse(body)
return result.Value()
}
func DeleteMember(url, token string) interface{} {
body, code := httper2.ZeroTierDelete(url, GetHead(token))
if code != http.StatusOK {
return ""
}
result := gjson.Parse(body)
return result.Value()
}
func GetHead(token string) map[string]string {
var head = make(map[string]string)
head["Authorization"] = "Bearer " + token
head["Content-Type"] = "application/json"
return head
}