package endpoints import ( "encoding/json" "github.com/imosed/signet/auth" . "github.com/imosed/signet/data" "net/http" ) type CloseRewardFundRequest struct { ID uint `json:"id"` Close bool `json:"close"` } func CloseRewardFund(w http.ResponseWriter, r *http.Request) { var req CloseRewardFundRequest err := json.NewDecoder(r.Body).Decode(&req) if err != nil { panic("Could not decode body") } var claims *auth.Claims claims, err = auth.GetUserClaims(r) if err != nil { panic("Could not determine if user is authenticated") } var fund RewardFund var modified int64 if claims.Privileges <= AdminPlus && req.Close { Db.Table("reward_funds").Find(&fund, req.ID) modified = Db.Delete(&fund).RowsAffected } var resp SuccessResponse resp.Success = modified > 0 err = json.NewEncoder(w).Encode(resp) if err != nil { panic("Could not deliver response") } }