fix(server/registry): use url.Value.Encode()

Instead of open coding url encoding which lead to error, make it real
and use the library.
This commit is contained in:
Brandon Philips
2013-12-13 12:37:12 -08:00
parent e24d2fdb6c
commit 7e5aa3137d
2 changed files with 5 additions and 4 deletions

View File

@@ -38,14 +38,16 @@ func NewRegistry(s store.Store) *Registry {
}
// Adds a node to the registry.
func (r *Registry) Register(name string, peerURL string, url string) error {
func (r *Registry) Register(name string, peerURL string, machURL string) error {
r.Lock()
defer r.Unlock()
// Write data to store.
key := path.Join(RegistryKey, name)
value := fmt.Sprintf("raft=%s&etcd=%s", peerURL, url)
_, err := r.store.Create(key, false, value, false, store.Permanent)
v := url.Values{}
v.Set("raft", peerURL)
v.Set("etcd", machURL)
_, err := r.store.Create(key, false, v.Encode(), false, store.Permanent)
log.Debugf("Register: %s", name)
return err
}