boskos/boskos.go
func handleReset(r *ranch.Ranch) http.HandlerFunc {
	return func(res http.ResponseWriter, req *http.Request) {
		logrus.WithField("handler", "handleReset").Infof("From %v", req.RemoteAddr)

		if req.Method != http.MethodPost {
			msg := fmt.Sprintf("Method %v, /reset only accepts POST.", req.Method)
			logrus.Warning(msg)
			http.Error(res, msg, http.StatusMethodNotAllowed)
			return
		}

		rtype := req.URL.Query().Get("type")
		state := req.URL.Query().Get("state")
		expireStr := req.URL.Query().Get("expire")
		dest := req.URL.Query().Get("dest")

		logrus.Infof("%v, %v, %v, %v", rtype, state, expireStr, dest)

		if rtype == "" || state == "" || expireStr == "" || dest == "" {
			msg := fmt.Sprintf("Type: %v, state: %v, expire: %v, dest: %v, all of them must be set in the request.", rtype, state, expireStr, dest)
			logrus.Warning(msg)
			http.Error(res, msg, http.StatusBadRequest)
			return
		}

		expire, err := time.ParseDuration(expireStr)
		if err != nil {
			logrus.WithError(err).Errorf("Invalid expiration: %v", expireStr)
			http.Error(res, err.Error(), http.StatusBadRequest)
			return
		}

		rmap, err := r.Reset(rtype, state, expire, dest)
		if err != nil {
			logrus.WithError(err).Errorf("could not reset states")
			http.Error(res, err.Error(), http.StatusBadRequest)
			return
		}
		resJSON, err := json.Marshal(rmap)
		if err != nil {
			logrus.WithError(err).Errorf("json.Marshal failed: %v", rmap)
			http.Error(res, err.Error(), ErrorToStatus(err))
			return
		}
		logrus.Infof("Resource %v reset successful, %d items moved to state %v", rtype, len(rmap), dest)
		fmt.Fprint(res, string(resJSON))
	}
}
func handleReset(r *ranch.Ranch) http.HandlerFunc {
	return func(res http.ResponseWriter, req *http.Request) {
		logrus.WithField("handler", "handleReset").Infof("From %v", req.RemoteAddr)

		if req.Method != http.MethodPost {
			msg := fmt.Sprintf("Method %v, /reset only accepts POST.", req.Method)
			logrus.Warning(msg)
			http.Error(res, msg, http.StatusMethodNotAllowed)
			return
		}

		rtype := req.URL.Query().Get("type")
		state := req.URL.Query().Get("state")
		expireStr := req.URL.Query().Get("expire")
		dest := req.URL.Query().Get("dest")

		logrus.Infof("%v, %v, %v, %v", rtype, state, expireStr, dest)

		if rtype == "" || state == "" || expireStr == "" || dest == "" {
			msg := fmt.Sprintf("Type: %v, state: %v, expire: %v, dest: %v, all of them must be set in the request.", rtype, state, expireStr, dest)
			logrus.Warning(msg)
			http.Error(res, msg, http.StatusBadRequest)
			return
		}

		expire, err := time.ParseDuration(expireStr)
		if err != nil {
			logrus.WithError(err).Errorf("Invalid expiration: %v", expireStr)
			http.Error(res, err.Error(), http.StatusBadRequest)
			return
		}

		rmap, err := r.Reset(rtype, state, expire, dest)
		if err != nil {
			logrus.WithError(err).Errorf("could not reset states")
			http.Error(res, err.Error(), http.StatusBadRequest)
			return
		}
		resJSON, err := json.Marshal(rmap)
		if err != nil {
			logrus.WithError(err).Errorf("json.Marshal failed: %v", rmap)
			http.Error(res, err.Error(), ErrorToStatus(err))
			return
		}
		logrus.Infof("Resource %v reset successful, %d items moved to state %v", rtype, len(rmap), dest)
		fmt.Fprint(res, string(resJSON))
	}
}
func handleReset ( r * ranch . Ranch ) http . HandlerFunc { return func ( res http . ResponseWriter , req * http . Request ) { logrus . WithField ( " " , " " ) . Infof ( " " , req . RemoteAddr ) if req . Method != http . MethodPost { msg := fmt . Sprintf ( " " , req . Method ) logrus . Warning ( msg ) http . Error ( res , msg , http . StatusMethodNotAllowed ) return } rtype := req . URL . Query ( ) . Get ( " " ) state := req . URL . Query ( ) . Get ( " " ) expireStr := req . URL . Query ( ) . Get ( " " ) dest := req . URL . Query ( ) . Get ( " " ) logrus . Infof ( " " , rtype , state , expireStr , dest ) if rtype == " " || state == " " || expireStr == " " || dest == " " { msg := fmt . Sprintf ( " " , rtype , state , expireStr , dest ) logrus . Warning ( msg ) http . Error ( res , msg , http . StatusBadRequest ) return } expire , err := time . ParseDuration ( expireStr ) if err != nil { logrus . WithError ( err ) . Errorf ( " " , expireStr ) http . Error ( res , err . Error ( ) , http . StatusBadRequest ) return } rmap , err := r . Reset ( rtype , state , expire , dest ) if err != nil { logrus . WithError ( err ) . Errorf ( " " ) http . Error ( res , err . Error ( ) , http . StatusBadRequest ) return } resJSON , err := json . Marshal ( rmap ) if err != nil { logrus . WithError ( err ) . Errorf ( " " , rmap ) http . Error ( res , err . Error ( ) , ErrorToStatus ( err ) ) return } logrus . Infof ( " " , rtype , len ( rmap ) , dest ) fmt . Fprint ( res , string ( resJSON ) ) } }
//  handleReset: Handler for /reset
//  Method: POST
//	URL Params:
//		Required: type=[string] : type of resource in interest
//		Required: state=[string] : original state
//		Required: dest=[string] : dest state, for expired resource
//		Required: expire=[durationStr*] resource has not been updated since before {expire}.
handleReset : Handler for / reset Method : POST URL Params : Required : type = [ string ] : type of resource in interest Required : state = [ string ] : original state Required : dest = [ string ] : dest state for expired resource Required : expire = [ durationStr * ] resource has not been updated since before { expire } .