Compare commits

..

1 Commits

Author SHA1 Message Date
cd72620e49 add HttpPostJSON 2025-05-23 10:45:28 +08:00

View File

@@ -2,6 +2,7 @@ package utils
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
@@ -121,6 +122,15 @@ func HttpGet(url string) ([]byte, error) {
return body, err
}
func HttpPostJSON(url string, header map[string]string, data map[string]any) ([]byte, error) {
bytes, err := json.Marshal(data)
if err != nil {
return nil, err
}
return HttpPost(url, header, bytes)
}
func HttpPost(url string, header map[string]string, data []byte) ([]byte, error) {
var err error
reader := bytes.NewBuffer(data)