Initialise `allowedMethods` in init()

This commit is contained in:
Edd Steel 2018-02-17 17:31:24 -08:00
parent 77f19f7505
commit f5af8b0f03
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 { if endpoints == nil {
endpoints = make(map[string]unboundEndpoint) endpoints = make(map[string]unboundEndpoint)
} }
if allowedMethods == nil {
allowedMethods = make(map[string][]string)
}
if endpoints[pattern] != nil || allowedMethods[pattern] != nil { if endpoints[pattern] != nil || allowedMethods[pattern] != nil {
panic(fmt.Errorf("Pattern %q is already registered", pattern)) panic(fmt.Errorf("Pattern %q is already registered", pattern))
} }

View File

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