Initialise `allowedMethods` in init()

This commit is contained in:
Edd Steel 2018-02-17 17:31:24 -08:00
parent 40eefc9f7d
commit 4dc9d2ebd7
No known key found for this signature in database
GPG Key ID: 33620159D40385A0
2 changed files with 2 additions and 3 deletions

View File

@ -60,9 +60,6 @@ func registerEndpoint(pattern string, methods []string, fn unboundEndpoint) {
if endpoints == nil {
endpoints = make(map[string]unboundEndpoint)
}
if allowedMethods == nil {
allowedMethods = make(map[string][]string)
}
if endpoints[pattern] != nil || allowedMethods[pattern] != nil {
panic(fmt.Errorf("Pattern %q is already registered", pattern))
}

View File

@ -1,6 +1,8 @@
package agent
func init() {
allowedMethods = make(map[string][]string)
registerEndpoint("/v1/acl/bootstrap", []string{"PUT"}, (*HTTPServer).ACLBootstrap)
registerEndpoint("/v1/acl/create", []string{"PUT"}, (*HTTPServer).ACLCreate)
registerEndpoint("/v1/acl/update", []string{"PUT"}, (*HTTPServer).ACLUpdate)