Skip to content

Instantly share code, notes, and snippets.

@nkreiger
Last active June 23, 2021 02:34
Show Gist options
  • Save nkreiger/cbf13fc4afe23d55dcb529f7dbe98741 to your computer and use it in GitHub Desktop.
Save nkreiger/cbf13fc4afe23d55dcb529f7dbe98741 to your computer and use it in GitHub Desktop.
dynamic url simple example
type Formatter func() (string, *url.URL)
func (w *weatherAPI) ForecastURL(date, region string) Formatter {
return func() (string, *url.URL) {
u := &url.URL{
Scheme: w.Scheme,
Host: w.Host,
Path: w.Endpoints.Forecast.Path,
}
rq := u.Query()
rq.Set("dateKey", date)
rq.Set("regionKey", region)
u.RawQuery = rq.Encode()
return http.MethodGet, u
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment