package main import ( "biukop.com/sfm/loan" "encoding/json" log "github.com/sirupsen/logrus" "net/http" ) type UserExtra struct { Enabled bool Login string BSB string ACC string License string Organization string Role string } func decodeJsonUserExtra(r *http.Request) (ret UserExtra, e error) { decoder := json.NewDecoder(r.Body) //decoder.DisallowUnknownFields() e = decoder.Decode(&ret) if e != nil { log.Error("failed decoding PayIn for updating", e.Error()) return } return } func apiV1UserPost(w http.ResponseWriter, r *http.Request, ss *loan.Session) { id := r.URL.Path[len(apiV1Prefix+"user/"):] //remove prefix input, e := decodeJsonUserExtra(r) log.Println(input) if e != nil { apiV1Client404Error(w, r, ss) return } else { u := loan.User{} e = u.Read(id) if e != nil { log.Error("cannot save basic loan", e.Error()) apiV1SendJson(" [ Error Occurred ] : "+e.Error(), w, r, ss) return } u.Enabled = input.Enabled u.Login = input.Login e = u.Write() if e != nil { log.Error("cannot save basic loan", e.Error()) apiV1SendJson(" [ Error Occurred ] : "+e.Error(), w, r, ss) } else { apiV1SendJson(input.Login, w, r, ss) } } }