You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
478 B

package jst
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"recook/internal/v2/lib/jst/resp"
)
func postJson(url string, data []byte) (*resp.JSTBack, error) {
c := http.Client{}
response, e := c.Post(url, "application/json", bytes.NewBuffer(data))
if e != nil {
return nil, e
}
defer response.Body.Close()
body, e := ioutil.ReadAll(response.Body)
var j resp.JSTBack
e = json.Unmarshal(body, &j)
if e != nil {
return nil, e
}
return &j, nil
}