|
6 | 6 | "errors" |
7 | 7 | "fmt" |
8 | 8 | "net/http" |
| 9 | + "net/url" |
9 | 10 | "strconv" |
10 | 11 | "strings" |
11 | 12 | texttemplate "text/template" |
@@ -126,8 +127,17 @@ type newrelicApplicationsResponse struct { |
126 | 127 | } |
127 | 128 |
|
128 | 129 | func (s newrelicService) getApplicationId(client *http.Client, appName string) (string, error) { |
129 | | - applicationsApi := fmt.Sprintf("%s/v2/applications.json?filter[name]=%s", s.opts.ApiURL, appName) |
130 | | - req, err := http.NewRequest(http.MethodGet, applicationsApi, nil) |
| 130 | + u, err := url.Parse(s.opts.ApiURL) |
| 131 | + if err != nil { |
| 132 | + log.Errorf("Failed to parse ApiURL: %s", err) |
| 133 | + return "", err |
| 134 | + } |
| 135 | + u.Path = "/v2/applications.json" |
| 136 | + q := u.Query() |
| 137 | + q.Set("filter[name]", appName) |
| 138 | + u.RawQuery = q.Encode() |
| 139 | + |
| 140 | + req, err := http.NewRequest(http.MethodGet, u.String(), nil) |
131 | 141 | if err != nil { |
132 | 142 | return "", fmt.Errorf("Failed to create filtered application request: %s", err) |
133 | 143 | } |
@@ -204,8 +214,15 @@ func (s newrelicService) Send(notification Notification, dest Destination) (err |
204 | 214 | } |
205 | 215 | } |
206 | 216 | } |
207 | | - markerApi := fmt.Sprintf(s.opts.ApiURL+"/v2/applications/%s/deployments.json", appId) |
208 | | - req, err := http.NewRequest(http.MethodPost, markerApi, bytes.NewBuffer(jsonValue)) |
| 217 | + |
| 218 | + u, err := url.Parse(s.opts.ApiURL) |
| 219 | + if err != nil { |
| 220 | + log.Errorf("Failed to parse ApiURL: %s", err) |
| 221 | + return err |
| 222 | + } |
| 223 | + u.Path = fmt.Sprintf("/v2/applications/%s/deployments.json", appId) |
| 224 | + |
| 225 | + req, err := http.NewRequest(http.MethodPost, u.String(), bytes.NewBuffer(jsonValue)) |
209 | 226 | if err != nil { |
210 | 227 | log.Errorf("Failed to create deployment marker request: %s", err) |
211 | 228 | return err |
|
0 commit comments