Quellcode durchsuchen

build signature moved from ttest case to main code.

master
Patrick Peng Sun vor 8 Jahren
Ursprung
Commit
fa3b1462ac
2 geänderte Dateien mit 16 neuen und 14 gelöschten Zeilen
  1. +16
    -0
      server.go
  2. +0
    -14
      server_test.go

+ 16
- 0
server.go Datei anzeigen

return diff > sec return diff > sec
} }


func buildSignature(token string) (signature, timestamp, nonce string) {
timestamp = fmt.Sprintf("%d", int32(time.Now().Unix()))
nonce = "1461107899" //a randome string cut from previous wechat request
signature = calculateSignature(timestamp, nonce, token)
return
}

func buildReqCommonSignature(req *http.Request, token string) {
signature, timestamp, nonce := buildSignature(token)
q := req.URL.Query()
q.Add("signature", signature)
q.Add("timestamp", timestamp)
q.Add("nonce", nonce)
req.URL.RawQuery = q.Encode()
}

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

+ 0
- 14
server_test.go Datei anzeigen

return req return req
} }


func buildSignature(token string) (signature, timestamp, nonce string) {
timestamp = fmt.Sprintf("%d", int32(time.Now().Unix()))
nonce = "1461107899" //a randome string cut from previous wechat request
signature = calculateSignature(timestamp, nonce, token)
return
}


func buildReqCommonSignature(req *http.Request, token string) {
signature, timestamp, nonce := buildSignature(token)
q := req.URL.Query()
q.Add("signature", signature)
q.Add("timestamp", timestamp)
q.Add("nonce", nonce)
req.URL.RawQuery = q.Encode()
}


func buildReqCommonHeader(r *http.Request) { func buildReqCommonHeader(r *http.Request) {
// //

Laden…
Abbrechen
Speichern