http.NoBody
instead of nil
in http.NewRequest
calls GO-R4001 47// If an HTTP error is returned, the body is decoded as a DefaultJsonError JSON object and returned as the first return value.
48func (c BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error {
49 url := c.host + endpoint
50 req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) 51 if err != nil {
52 return errors.Wrapf(err, "failed to create request for endpoint %s", url)
53 }
78 allTopics := strings.Join(h.topics, ",")
79 log.WithField("topics", allTopics).Info("Listening to Beacon API events")
80 fullUrl := h.host + "/eth/v1/events?topics=" + allTopics
81 req, err := http.NewRequestWithContext(h.ctx, http.MethodGet, fullUrl, nil) 82 if err != nil {
83 eventsChannel <- &Event{
84 EventType: EventConnectionError,
http.NoBody
is an io.ReadCloser
with no bytes. Read always returns EOF
and
Close
always returns nil
.
func foo(url string) {
http.NewRequest("GET", url, nil)
}
func foo(url string) {
http.NewRequest("GET", url, http.NoBody)
}