Merge pull request #1 from darknesto/master

Properly closing response body
This commit is contained in:
Christopher Herrera 2014-09-26 10:23:02 -04:00
commit 4e9f9dc017

View file

@ -104,9 +104,11 @@ func SearchMovies(title string, year string) (*SearchResponse, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
r := new(SearchResponse)
err = json.NewDecoder(resp.Body).Decode(r)
if err != nil {
return nil, err
}
@ -123,9 +125,11 @@ func GetMovieByTitle(title string, year string) (*MovieResult, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
r := new(MovieResult)
err = json.NewDecoder(resp.Body).Decode(r)
defer resp.Body.Close()
if err != nil {
return nil, err
}
@ -141,9 +145,11 @@ func GetMovieByImdbId(id string) (*MovieResult, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
r := new(MovieResult)
err = json.NewDecoder(resp.Body).Decode(r)
defer resp.Body.Close()
if err != nil {
return nil, err
}