mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-21 09:19:16 +08:00
39 lines
765 B
Go
39 lines
765 B
Go
package http
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
|
"net/http"
|
|
)
|
|
|
|
func PostLocalCore(url string) error {
|
|
settingRepo := repo.NewISettingRepo()
|
|
port, err := settingRepo.GetValueByKey("ServerPort")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
sslStatus, err := settingRepo.GetValueByKey("SSL")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var prefix string
|
|
if sslStatus == "Disable" {
|
|
prefix = "http://"
|
|
} else {
|
|
prefix = "https://"
|
|
}
|
|
reloadURL := fmt.Sprintf("%s://127.0.0.1:%s/api/v2%s", prefix, port, url)
|
|
req, err := http.NewRequest("POST", reloadURL, bytes.NewBuffer([]byte{}))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer resp.Body.Close()
|
|
return nil
|
|
}
|