summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nws/nws.go24
-rw-r--r--version/version.go2
2 files changed, 5 insertions, 21 deletions
diff --git a/nws/nws.go b/nws/nws.go
index 6f75979..567d1a8 100644
--- a/nws/nws.go
+++ b/nws/nws.go
@@ -74,30 +74,14 @@ func (e Error) Error() string {
// TODO: return Error instead of error
func Points(lat, lng float32) (*Point, error) {
url := fmt.Sprintf("https://api.weather.gov/points/%.4f,%.4f", lat, lng)
- resp, err := client.Get(url)
- if err != nil {
- return nil, fmt.Errorf("points: http get: %v", err)
- }
-
- // Parse response body.
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return nil, fmt.Errorf("points: body: %v", err)
- }
-
- // Check if the request failed.
- if resp.StatusCode != 200 {
- perr := new(Error)
- err := json.Unmarshal(body, perr)
- if err != nil {
- return nil, fmt.Errorf("points: json: %v", err)
- }
- return nil, fmt.Errorf("points: %v", perr)
+ body, nwsErr := get(url)
+ if nwsErr != nil {
+ return nil, fmt.Errorf("points: %v", nwsErr)
}
// Unmarshal.
point := new(Point)
- err = json.Unmarshal(body, point)
+ err := json.Unmarshal(body, point)
if err != nil {
return nil, fmt.Errorf("points: decode: %v", err)
}
diff --git a/version/version.go b/version/version.go
index ae475bd..2e34600 100644
--- a/version/version.go
+++ b/version/version.go
@@ -4,4 +4,4 @@
// Peach version.
package version
-const Version = "0.2.0.dev1"
+const Version = "0.2.0.dev2"