20 lines
322 B
Go
20 lines
322 B
Go
package ezhttp
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
func Do(req *http.Request) (*http.Response, error) {
|
|
return http.DefaultClient.Do(req)
|
|
}
|
|
|
|
func ParseJsonResponse[T any](r io.Reader) (*T, error) {
|
|
res := new(T)
|
|
if err := json.NewDecoder(r).Decode(res); err != nil {
|
|
return nil, err
|
|
}
|
|
return res, nil
|
|
}
|