package restserver import ( "net/http" "git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model" ) func (r *RestServer) configureRouterUser() { r.router.HandleFunc("/api/register", r.HandleFuncRegUser()).Methods("POST") } func (r *RestServer) HandleFuncRegUser() http.HandlerFunc { return func(w http.ResponseWriter, res *http.Request) { user := model.User{} err := res.ParseForm() if err != nil { r.logger.Error(err) } user.Id = 1 user.Login = res.Form.Get("user") user.Password = res.Form.Get("password") user.Email = res.Form.Get("email") user.PermisionLVL = 1 user.Token = "dasf2!23sfafaQWerq" RetUser, err := r.db.User().Create(&user) if err != nil { r.logger.Errorln(err) } if RetUser != nil { r.logger.Infoln("Create new user with id = ", RetUser.Id, " and with permissionLvl = ", RetUser.Id) } } }