Beispiel #1
0
// TODO
func (u *User) Profile(response http.ResponseWriter, request *http.Request) {
	user_id, _ := utilities.GetUserId(request)
	db := utilities.GetDB(request)
	user := new(models.User)
	user.Get(db, user_id)
	user.Password = ""
	out, _ := json.Marshal(user)
	response.Write(out)
}
Beispiel #2
0
/// Method for the user struct that takes an HTTP request and
// returns an HTTP response containing the user's details for
// their ID.
func (u *User) Get(response http.ResponseWriter, request *http.Request) {
	vars := mux.Vars(request)
	id := vars["id"]

	db := utilities.GetDB(request)
	user := new(models.User)
	err := user.Get(db, id)
	if err != nil {
		response.WriteHeader(404)
	} else {
		user.Password = ""
		out, _ := json.Marshal(user)
		response.Write(out)
	}
}