package auth import ( "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils" "net/url" "strings" ) func signHttpRequest(request requests.AcsRequest, signer Signer) (err error) { err = completeHttpSignParams(request, signer) if err != nil { return } if _, isContainsSign := request.GetQueryParams()["Sign"]; isContainsSign { delete(request.GetQueryParams(), "Sign") } stringToSign := buildHttpStringToSign(request) request.SetStringToSign(stringToSign) signature := signer.Sign(stringToSign, "&") request.GetQueryParams()["Sign"] = signature return } func completeHttpSignParams(requests requests.AcsRequest, signer Signer) (err error) { return } func buildHttpStringToSign(request requests.AcsRequest) (stringToSign string) { signParams := make(map[string]string) for key, value := range request.GetQueryParams() { signParams[key] = value } for key, value := range request.GetFormParams() { signParams[key] = value } stringToSign = utils.GetUrlFormedMap(signParams) stringToSign = strings.Replace(stringToSign, "+", "%20", -1) stringToSign = strings.Replace(stringToSign, "*", "%2A", -1) stringToSign = strings.Replace(stringToSign, "%7E", "~", -1) stringToSign = url.QueryEscape(stringToSign) stringToSign = request.GetMethod() + "&%2F&" + stringToSign return }