run as non root and non host network mode

This commit is contained in:
yusing
2025-01-31 06:32:09 +08:00
parent 357897a0cd
commit b3290e2665
15 changed files with 107 additions and 73 deletions

View File

@@ -1,7 +1,9 @@
package utils
import (
"bytes"
"crypto/tls"
"io"
"net"
"net/http"
@@ -26,3 +28,15 @@ var (
Post = httpClient.Post
Head = httpClient.Head
)
func FetchAPI(method, endpoint string, body []byte) (*http.Response, error) {
var bodyReader io.Reader
if body != nil {
bodyReader = bytes.NewReader(body)
}
req, err := http.NewRequest(method, "http://localhost"+common.APIHTTPAddr+endpoint, bodyReader)
if err != nil {
return nil, err
}
return httpClient.Do(req)
}