Skip to content

Commit

Permalink
issue/28: Exposing http client for google geocoder
Browse files Browse the repository at this point in the history
  • Loading branch information
kellydunn committed Jan 14, 2015
1 parent 0404e6b commit 3a225e0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions google_geocoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (

// This struct contains all the funcitonality
// of interacting with the Google Maps Geocoding Service
type GoogleGeocoder struct{}
type GoogleGeocoder struct{
HttpClient *http.Client
}

// This struct contains selected fields from Google's Geocoding Service response
type googleGeocodeResponse struct {
Expand Down Expand Up @@ -44,7 +46,11 @@ func SetGoogleGeocodeURL(newGeocodeURL string) {
// Issues a request to the google geocoding service and forwards the passed in params string
// as a URL-encoded entity. Returns an array of byes as a result, or an error if one occurs during the process.
func (g *GoogleGeocoder) Request(params string) ([]byte, error) {
client := &http.Client{}
if g.HttpClient == nil {
g.HttpClient = &http.Client{}
}

client := g.HttpClient

fullUrl := fmt.Sprintf("%s?sensor=false&%s", googleGeocodeURL, params)

Expand Down

0 comments on commit 3a225e0

Please sign in to comment.