Skip to content

Commit

Permalink
fixbug: can not parse url query (#33)
Browse files Browse the repository at this point in the history
* fixbug: can not parse url query

* fixbug: grpc consul resolver can not parse url query params
  • Loading branch information
haozzzzzzzz authored Mar 22, 2023
1 parent 9938c1d commit 1adaa17
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 265 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
go.sum
4 changes: 3 additions & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const schemeName = "consul"
type builder struct{}

func (b *builder) Build(url resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
dsn := strings.Join([]string{schemeName + ":/", url.Authority, url.Endpoint}, "/")
//dsn := strings.Join([]string{schemeName + ":/", url.Authority, url.Endpoint}, "/")
//dsn += "?" + url.URL.RawQuery
dsn := strings.Join([]string{schemeName + ":/", url.URL.Host, url.URL.Path + "?" + url.URL.RawQuery}, "/")
tgt, err := parseURL(dsn)
if err != nil {
return nil, errors.Wrap(err, "Wrong consul URL")
Expand Down
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ require (
github.com/jpillora/backoff v1.0.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/genproto v0.0.0-20200210034751-acff78025515 // indirect
google.golang.org/grpc v1.27.1
github.com/stretchr/testify v1.7.0
google.golang.org/grpc v1.48.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
)
Loading

0 comments on commit 1adaa17

Please sign in to comment.