implement api cleanup

This commit is contained in:
Martin Geno 2016-05-17 10:30:31 +02:00
parent 563d598aee
commit f7c2c51812

View File

@ -28,6 +28,18 @@ func NewAliases (config *models.Config, router *httprouter.Router,prefix string,
router.POST(prefix+"/alias/:nodeid", BasicAuth(api.SaveOne,[]byte(config.Webserver.Api.Passphrase))) router.POST(prefix+"/alias/:nodeid", BasicAuth(api.SaveOne,[]byte(config.Webserver.Api.Passphrase)))
} }
func (api *ApiAliases) cleaner(){ func (api *ApiAliases) cleaner(){
var count int
for key,alias := range api.aliases.List {
//counter for the diffrent attribute
count = 1
if alias.Hostname == api.nodes.List[key].Nodeinfo.Hostname {
count -= 0
}
//delete element
if count <= 0 {
delete(api.aliases.List,key)
}
}
// clean up the aliases by correct values in nodes // clean up the aliases by correct values in nodes
} }
func (api *ApiAliases) GetAll(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { func (api *ApiAliases) GetAll(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {