Last active
June 23, 2021 02:34
-
-
Save nkreiger/cbf13fc4afe23d55dcb529f7dbe98741 to your computer and use it in GitHub Desktop.
dynamic url simple example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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