Skip to content

Commit

Permalink
FixBug: can't delete node by path (apache#201)
Browse files Browse the repository at this point in the history
* fix bug can't delete node

* rm return statement

Former-commit-id: 2b4af4d
  • Loading branch information
ztelur authored Jul 4, 2021
1 parent 66934a8 commit 1a21b7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions pkg/config/api_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ func listenResourceAndMethodEvent(key string) bool {
case mvccpb.DELETE:
logger.Infof("get event (key{%s}) = event{EventNodeDeleted}", event.Kv.Key)
handleDeleteEvent(event.Kv.Key, event.Kv.Value)
return true
default:
return false
logger.Infof("get event (key{%s}) = event{%d}", event.Kv.Key, event.Type)
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions pkg/router/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ func (rt *Route) FindAPI(fullPath string, httpverb config.HTTPVerb) (*router.API
// DeleteNode delete node by fullPath
func (rt *Route) DeleteNode(fullPath string) bool {
lowerPath := strings.ToLower(fullPath)
if _, found := rt.searchWildcard(lowerPath); found {
rt.lock.RLock()
defer rt.lock.RUnlock()
rt.tree.Remove(lowerPath)
return true
}
return false
rt.lock.RLock()
defer rt.lock.RUnlock()
rt.tree.Remove(lowerPath)
return true
}

// DeleteAPI delete api by fullPath and http verb
Expand Down

0 comments on commit 1a21b7f

Please sign in to comment.