func setActiveUntilImp(r *http.Request, activeUntil time.Time) (err error) { if r.Method != "POST" { err = fmt.Errorf("Must use POST") return } ip := r.FormValue("ip") deviceIP := db.ParseDeviceIP(ip) err = watch.SetActiveUntil(deviceIP, activeUntil) if err != nil { return } return }
func modifyActiveUntilImp(r *http.Request) (err error) { if r.Method != "POST" { err = fmt.Errorf("Must use POST") return } ip := r.FormValue("ip") if ip == "" { err = fmt.Errorf("Missing ip parameter") return } deviceIP := db.ParseDeviceIP(ip) delta, err := time.ParseDuration(r.FormValue("delta")) if err != nil { return } err = watch.ModifyActiveUntil(deviceIP, delta) if err != nil { return } return }