-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
32 lines (28 loc) · 804 Bytes
/
Copy pathutils.go
File metadata and controls
32 lines (28 loc) · 804 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
28
29
30
31
32
package httpx
import (
"fmt"
"net/http"
"sort"
"strings"
)
// messageForSigning concatenates passed request data in a fixed format.
func messageForSigning(service, method, url, body, authHeaders string) string {
return fmt.Sprintf("service:%s;method:%s;path:%s;authHeaders:%s;body:%s;",
service, method, url, authHeaders, body)
}
// addCookies sets all `cookies` to the http.Request.
func addCookies(r *http.Request, cookies []*http.Cookie) *http.Request {
for _, k := range cookies {
r.AddCookie(k)
}
return r
}
// headersForSigning concatenates passed keys from headers map
func headersForSigning(headers map[string]string) string {
keys := make([]string, 0, len(headers))
for key := range headers {
keys = append(keys, key)
}
sort.Strings(keys)
return strings.Join(keys, ":")
}