package otherapi import ( "bytes" "encoding/json" "io" "net/http" ) func http_post(url string, request, reply any) error { jsonData, err := json.Marshal(request) if err != nil { return err } httpRequest, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData)) if err != nil { return err } httpRequest.Header.Set("Content-Type", "application/json") client := &http.Client{} response, err := client.Do(httpRequest) if err != nil { return err } defer response.Body.Close() body, err := io.ReadAll(response.Body) if err != nil { return err } return json.Unmarshal(body, reply) }