Ejemplo n.º 1
0
func DeleteUser(w http.ResponseWriter, r *http.Request) {
	user := model.User{}
	user.UserID = context.Get(r, "user_id").(uint64)
	err := user.Get()
	if err != nil {
		reply.Err(w, ae.DB("", err))
	}
	err = user.Delete()
	if err != nil {
		reply.Err(w, ae.DB("", err))
	}
	reply.OK(w, user)
}
Ejemplo n.º 2
0
func GetUser(w http.ResponseWriter, r *http.Request) {
	userID := context.Get(r, "user_id").(uint64)
	var err error

	urlParams := context.Get(r, "params").(httprouter.Params)
	id := urlParams.ByName("id")
	if len(id) != 0 {
		userID, err = strconv.ParseUint(id, 10, 64)
		if err != nil {
			reply.Err(w, ae.InvalidInput("id is not a number", "id"))
		}
	}

	user := model.User{}
	user.UserID = userID
	err = user.Get()
	if err != nil {
		reply.Err(w, ae.DB("", err))
		return
	}

	reply.OK(w, user)
}