예제 #1
0
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)
	}

}
예제 #2
0
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)
	}

}