func GetUserCpe(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) var cpes []dbconn.Cpe var cpe dbconn.Cpe var err error cpe.Userid, err = strconv.ParseInt(vars["Userid"], 10, 64) cpes, err = cpe.Gets() if err != nil { http.Error(w, err.Error(), 500) return } w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusCreated) if err := json.NewEncoder(w).Encode(cpes); err != nil { panic(err) } }
func GetCpes(w http.ResponseWriter, r *http.Request) { var cpes []dbconn.Cpe var cpe dbconn.Cpe if err := cpe.Parse(w, r); err != nil { http.Error(w, err.Error(), 500) return } cpes, err := cpe.Gets() if err != nil { http.Error(w, err.Error(), 500) return } w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusCreated) if err := json.NewEncoder(w).Encode(cpes); err != nil { panic(err) } }