webcmd/twa_ClearCompleted.go

20 lines
298 B
Go
Raw Normal View History

2017-03-25 02:41:36 +00:00
package webcmd
import (
"net/http"
)
func (this *App) Action_ClearCompleted(w http.ResponseWriter, r *http.Request) {
this.tasksMtx.Lock()
defer this.tasksMtx.Unlock()
for k, v := range this.tasks {
if v.Finished() {
delete(this.tasks, k)
}
}
http.Redirect(w, r, "/tasks", 302)
}