package endpoints import ( "encoding/json" "net/http" "github.com/imosed/signet/auth" . "github.com/imosed/signet/data" ) type GetUsersResponse struct { Users []User `json:"users"` } func GetUsers(w http.ResponseWriter, r *http.Request) { claims, err := auth.GetUserClaims(r) if claims.Privileges > AdminPlus { return } var users []User Db.Table("users").Where("privileges >= ?", claims.Privileges).Scan(&users) var resp GetUsersResponse resp.Users = users err = json.NewEncoder(w).Encode(resp) if err != nil { panic("Could not deliver response") } }