|
@@ -32,6 +32,20 @@ func GetUnits() (models.Units, error) {
|
|
|
return units, nil
|
|
|
}
|
|
|
|
|
|
+func GetPeople() (models.People, error) {
|
|
|
+ var people models.People
|
|
|
+ buf, err := getJSON("https://sd.mephi.ru/api/1/faces.json")
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := json.Unmarshal(buf.Bytes(), &people); err != nil {
|
|
|
+ return nil, fmt.Errorf("Cannot parse: %v: \"%v\"", string(buf.Bytes()), err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ return people, nil
|
|
|
+}
|
|
|
+
|
|
|
func getJSON(url string) (*bytes.Buffer, error) {
|
|
|
client := &http.Client{}
|
|
|
|