Skip to content

Commit

Permalink
Support add query to existing query
Browse files Browse the repository at this point in the history
  • Loading branch information
hiepnv90 committed Jul 11, 2024
1 parent 7560068 commit 92fefac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/httpclient/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func NewRequestWithContext(
u = u.JoinPath(path)
}
if query != nil {
existingQuery := u.Query()
for key, values := range existingQuery {
for _, value := range values {
query.AddString(key, value)
}
}
u.RawQuery = query.String()
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/httpclient/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func (q Query) SetString(key, value string) Query {
return q
}

func (q Query) AddString(key, value string) Query {
q.url().Add(key, value)
return q
}

func stringsContains(ss []string, token string) bool {
for _, s := range ss {
if s == token {
Expand Down

0 comments on commit 92fefac

Please sign in to comment.