ezhttp/do.go

20 lines
322 B
Go
Raw Normal View History

2024-09-11 13:32:52 +02:00
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
}