forked from keighl/postmark
-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathhelpers.go
More file actions
27 lines (23 loc) · 609 Bytes
/
Copy pathhelpers.go
File metadata and controls
27 lines (23 loc) · 609 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package postmark
import (
"fmt"
"net/url"
)
// buildURLWithQuery constructs a URL with the given path and query parameters.
func buildURLWithQuery(path string, queryParams url.Values) string {
if len(queryParams) == 0 {
return path
}
return fmt.Sprintf("%s?%s", path, queryParams.Encode())
}
// buildURL constructs a URL with the given path and options.
func buildURL(path string, options map[string]interface{}) string {
if options == nil {
return path
}
values := &url.Values{}
for k, v := range options {
values.Add(k, fmt.Sprintf("%v", v))
}
return buildURLWithQuery(path, *values)
}