Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _examples/encoding/jsonreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func main() {
if err != nil {
log.Fatalf("Error getting response: %s", err)
}

log.Println(res)
res.Body.Close()

query := map[string]interface{}{
"query": map[string]interface{}{
Expand All @@ -77,6 +77,7 @@ func main() {
if err != nil {
log.Fatalf("Error getting response: %s", err)
}
defer res.Body.Close()

log.Println(res)
}
7 changes: 6 additions & 1 deletion _examples/extension/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ func main() {

// --> Call a custom API
//
es.Custom.Example()
res, err := es.Custom.Example()
if err != nil {
log.Fatalf("Error calling custom API: %s", err)
}
defer res.Body.Close()
log.Println(res.Status())
}

func startServer(started chan<- bool) {
Expand Down
1 change: 1 addition & 0 deletions _examples/fasthttp/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func main() {
if err != nil {
log.Fatalf("Error getting response: %s", err)
}
defer res.Body.Close()
if res.IsError() {
log.Fatalf("Error response: %s", res)
}
Expand Down
1 change: 1 addition & 0 deletions _examples/security/tls_configure_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func main() {
if err != nil {
log.Fatalf("ERROR: Unable to get response: %s", err)
}
defer res.Body.Close()

log.Println(res)
}
1 change: 1 addition & 0 deletions _examples/security/tls_with_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func main() {
if err != nil {
log.Fatalf("ERROR: Unable to get response: %s", err)
}
defer res.Body.Close()

log.Println(res)
}
9 changes: 8 additions & 1 deletion esapi/esapi.response.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ import (
type Response struct {
StatusCode int
Header http.Header
Body io.ReadCloser
// Body is the response body. Callers must close Body when finished with
// it to release the underlying connection back to the pool. Failure to do
// so causes connection leaks. The idiomatic pattern is:
//
// res, err := es.Info()
// if err != nil { /* handle */ }
// defer res.Body.Close()
Body io.ReadCloser
}

// String returns the response as a string.
Expand Down