Przeglądaj źródła

build signature and append to existing url

master
Patrick Peng Sun 8 lat temu
rodzic
commit
2ee8d53913
1 zmienionych plików z 17 dodań i 0 usunięć
  1. +17
    -0
      server.go

+ 17
- 0
server.go Wyświetl plik

@@ -238,6 +238,23 @@ func buildReqCommonSignature(req *http.Request, token string) {
req.URL.RawQuery = q.Encode()
}

func buildSignatureAppend2Url(oldURL string, token string) (newURL string) {
u, err := url.Parse(oldURL)
if err != nil {
log.Println(err)
newURL = oldURL
return
}
signature, timestamp, nonce := buildSignature(token)
q := u.Query()
q.Add("signature", signature)
q.Add("timestamp", timestamp)
q.Add("nonce", nonce)
u.RawQuery = q.Encode()
newURL = u.String()
return
}

// func checkSignature1() bool {
// s1 := "e39de9f2e28079c01ebb4b803dfc3442b819545c"
// t1 := "1492970761"

Ładowanie…
Anuluj
Zapisz