Skip to content

Commit

Permalink
Merge pull request #58 from wenwenxiong/master
Browse files Browse the repository at this point in the history
adapted with consul v1.0 api change
  • Loading branch information
kobolog authored Apr 28, 2024
2 parents 8240420 + 7f256df commit 9c0b796
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions disco/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ func (c *consulDisco) Expose(name, host string, port uint16) error {
u := *c.consul
u.Path = "v1/agent/service/register"

r, err := c.client.Post(
u.String(),
"application/json",
bytes.NewBuffer(util.MustMarshal(exposeRequest{
Name: name,
Host: host,
Port: port,
}, util.JSONOptions{})))
req, _:= http.NewRequest("PUT", u.String(), bytes.NewBuffer(util.MustMarshal(exposeRequest{
Name: name,
Host: host,
Port: port,
}, util.JSONOptions{})))

req.Header.Add("Content-Type", "application/json")
r, err := c.client.Do(req)
if err != nil {
return err
}
Expand All @@ -88,7 +88,10 @@ func (c *consulDisco) Remove(name string) error {
u := *c.consul
u.Path = path.Join("v1/agent/service/deregister", name)

r, err := c.client.Get(u.String())
req, _:= http.NewRequest("PUT", u.String(),bytes.NewBuffer([]byte("")))

//r, err := c.client.Get(u.String())
r, err := c.client.Do(req)
if err != nil {
return err
}
Expand Down

0 comments on commit 9c0b796

Please sign in to comment.