Skip to content

Commit

Permalink
Update: oath v2 - apigw signature 만들 때 get method인 경우 paramter도 포함해서 …
Browse files Browse the repository at this point in the history
…만들도록 수정
  • Loading branch information
kihwan.kim committed Nov 27, 2020
1 parent 45ed101 commit f8b5e23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 4 additions & 8 deletions oauth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (c *Consumer) Debug(enabled bool) {
c.signer.Debug(enabled)
}

func (c *Consumer) GetRequest(url string) (string, io.Reader, error) {
func (c *Consumer) GetRequest(url string) (string, string, io.Reader, error) {
params := c.baseParams(c.AdditionalParams)

if c.debug {
Expand Down Expand Up @@ -233,15 +233,11 @@ func (c *Consumer) GetRequest(url string) (string, io.Reader, error) {
}

if req.method == "GET" {
if result == "" {
return req.url, nil, nil
}

return req.url + "?" + result, nil, nil
return req.url, result, nil, nil
} else if req.method == "POST" {
return req.url, strings.NewReader(result), nil
return req.url, "", strings.NewReader(result), nil
} else {
return "", nil, fmt.Errorf("Not supported method %s", req.method)
return "", "", nil, fmt.Errorf("Not supported method %s", req.method)
}
}

Expand Down
7 changes: 6 additions & 1 deletion request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ func NewRequest(accessKey, secretKey, method, url, urn string, params map[string
now := time.Now()
timestamp := strconv.FormatInt(int64(time.Nanosecond)*now.UnixNano()/int64(time.Millisecond), 10)

reqURL, body, err := c.GetRequest(url + urn)
reqURL, getParams, body, err := c.GetRequest(url + urn)
if err != nil {
return nil, nil, err
}

if method == "GET" && getParams != "" {
reqURL += "?" + getParams
urn += "?" + getParams
}

req, err := http.NewRequest(method, reqURL, body)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit f8b5e23

Please sign in to comment.