-
Notifications
You must be signed in to change notification settings - Fork 0
/
distributions.go
41 lines (37 loc) · 1006 Bytes
/
distributions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package www
import (
"net/http"
"github.com/csg33k/golug/services"
)
// ListDistros
// @Description List all users
// @Produce json
// @Success 200 {object} []string
// @Router /api/v1/distro/list [get]
func ListDistros(w http.ResponseWriter, r *http.Request) {
srv := services.GetServices()
distros, err := srv.ListDistributions()
if err != nil {
respondWithError(w, http.StatusInternalServerError, err.Error())
return
}
respondwithJSON(w, http.StatusOK, distros)
}
// ListDistros
// @Description List all users
// @Produce json
// @Success 200 {object} map[string]int64
// @Router /api/v1/distro/count [get]
func ListDistroCount(w http.ResponseWriter, r *http.Request) {
srv := services.GetServices()
distros, err := srv.LinuxDistroCount()
if err != nil {
respondWithError(w, http.StatusInternalServerError, err.Error())
return
}
result := make(map[string]int64)
for _, val := range distros {
result[val.LinuxDistro] = val.Count
}
respondwithJSON(w, http.StatusOK, result)
}