// HTMLForUser writes a specified view with user model to the response. func HTMLForUser(w http.ResponseWriter, r *http.Request, view string) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } user := &models.User{ID: uint64(id)} err = models.DB.Read(user) if err != nil { if err == sql.ErrNoRows { return } http.Error(w, err.Error(), http.StatusInternalServerError) return } flashes, err := Flashes(w, r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } views.HTML(w, view, models.NewUserCtx(r, user, nil, flashes)) }
func (_ User) New(w http.ResponseWriter, r *http.Request) { views.HTML(w, "user_new", models.NewUserCtx(r, new(models.User), nil, nil)) }