package request import ( "encoding/json" "net/http" "net/url" ) // Make request and process Body in target func MakeDoJSON(Url *url.URL, v any, Option *Options) (*http.Response, error) { res, err := MakeRequestWithStatus(Url, Option) if err != nil { return res, err } defer res.Body.Close() return res, json.NewDecoder(res.Body).Decode(v) } // Make request and return struct body func MakeJSON[T any](Url *url.URL, Option *Options) (v T, res *http.Response, err error) { res, err = MakeDoJSON(Url, &v, Option) return } // Make request and process Body in target func DoJSON(Url string, v any, Option *Options) (*http.Response, error) { requestUrl, err := url.Parse(Url) if err != nil { return nil, err } return MakeDoJSON(requestUrl, v, Option) } // Make request and return struct body func JSON[T any](Url string, Option *Options) (v T, res *http.Response, err error) { requestUrl, err2 := url.Parse(Url) if err2 != nil { err = err2 return } return MakeJSON[T](requestUrl, Option) }