Skip to content

Commit

Permalink
check handler func existence before adding it
Browse files Browse the repository at this point in the history
  • Loading branch information
newly12 committed Dec 16, 2020
1 parent ebc290c commit 8222f53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libbeat/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func prettyPrint(w http.ResponseWriter, data common.MapStr, u *url.URL) {
}

// AddHandlerFunc provides interface to add customized handlerFunc
func AddHandlerFunc(api string, h handlerFunc) {
func AddHandlerFunc(api string, h handlerFunc) error {
if _, exist := handlerFuncMap[api]; exist {
return fmt.Errorf("%s already exist", api)
}
handlerFuncMap[api] = h
return nil
}

0 comments on commit 8222f53

Please sign in to comment.