Implement Route.Delete()

Co-authored-by: pancho horrillo <pedrofelipe.horrillo@bbva.com>
This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-09 11:44:45 +02:00
parent 0249dc722b
commit 8729e1e492
2 changed files with 95 additions and 0 deletions
+14
View File
@@ -1,6 +1,7 @@
package state
import (
"errors"
"sync"
"github.com/BBVA/kapow/internal/server/model"
@@ -43,3 +44,16 @@ func (srl *safeRouteList) List() []model.Route {
}
return rs
}
func (srl *safeRouteList) Delete(ID string) error {
srl.m.Lock()
defer srl.m.Unlock()
for i := 0; i < len(srl.rs); i++ {
if srl.rs[i].ID == ID {
srl.rs = append(srl.rs[:i], srl.rs[i+1:]...)
return nil
}
}
return errors.New("Route not found")
}