route/vendor/github.com/Xe/x/tools/splattus/lib/handler.go

29 lines
396 B
Go
Raw Normal View History

2017-10-06 15:29:20 +00:00
package splattus
import (
"encoding/json"
"io/ioutil"
"net/http"
)
func Lookup() ([]SplatoonData, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var sd []SplatoonData
err = json.Unmarshal(body, &sd)
if err != nil {
return nil, err
}
return sd, nil
}