1.添加www(apisdk)项目接口
2.addheader 方法改成公有方法 3.添加文档
This commit is contained in:
parent
1f82a534c3
commit
b8b1585d5e
@ -172,3 +172,8 @@ func CreateDemoTestResponse() *DemoTestResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
终端调试打开方式, 需要在系统环境变量上加入
|
||||||
|
```
|
||||||
|
DEBUG=sdk,signer
|
||||||
|
```
|
@ -91,7 +91,7 @@ type AcsRequest interface {
|
|||||||
GetStringToSign() string
|
GetStringToSign() string
|
||||||
GetBodyReader() io.Reader
|
GetBodyReader() io.Reader
|
||||||
|
|
||||||
addHeaderParam(key, value string)
|
AddHeaderParam(key, value string)
|
||||||
addQueryParam(key, value string)
|
addQueryParam(key, value string)
|
||||||
addFormParam(key, value string)
|
addFormParam(key, value string)
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ func (request *baseRequest) SetStringToSign(stringToSign string) {
|
|||||||
request.stringToSign = stringToSign
|
request.stringToSign = stringToSign
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *baseRequest) addHeaderParam(key, val string) {
|
func (request *baseRequest) AddHeaderParam(key, val string) {
|
||||||
request.Headers[key] = val
|
request.Headers[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ func addParam(request AcsRequest, position, key, value string) (err error) {
|
|||||||
if len(value) > 0 {
|
if len(value) > 0 {
|
||||||
switch position {
|
switch position {
|
||||||
case Header:
|
case Header:
|
||||||
request.addHeaderParam(key, value)
|
request.AddHeaderParam(key, value)
|
||||||
case Query:
|
case Query:
|
||||||
request.addQueryParam(key, value)
|
request.addQueryParam(key, value)
|
||||||
case Body:
|
case Body:
|
||||||
|
44
services/www/client.go
Normal file
44
services/www/client.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package www
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2020-09-24"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST requests.Host = requests.Host{
|
||||||
|
Default: "apisdk.9ooo.cn",
|
||||||
|
Func: func(s string) string {
|
||||||
|
var a = map[string]string{
|
||||||
|
requests.RELEASE: "apisdk.9ooo.cn",
|
||||||
|
requests.PRE: "apisdk.9ooo.cn",
|
||||||
|
requests.TEST: "apisdk.9ooo.cn",
|
||||||
|
}
|
||||||
|
return a[s]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
||||||
|
client = &Client{}
|
||||||
|
err = client.InitWithAccessKey(accesskey, secrect, source)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClientWithAliAppcode(accesskey, secrect string, env ...string) (client *Client, err error) {
|
||||||
|
client = &Client{}
|
||||||
|
err = client.InitWithAliAppcode(accesskey, secrect, env...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err error) {
|
||||||
|
response = CreateGetPwdResponse()
|
||||||
|
err = c.DoAction(req, response)
|
||||||
|
return
|
||||||
|
}
|
21
services/www/client_test.go
Normal file
21
services/www/client_test.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package www
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestClient_GetUserInfo(t *testing.T) {
|
||||||
|
|
||||||
|
c, err := NewClientWithAliAppcode("203874304", "9e5489a82dd641729186cdad166d81a3")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := CreateGetPwdRequest()
|
||||||
|
req.UserName = "ttom666"
|
||||||
|
|
||||||
|
resp, _ := c.GetUserInfo(req)
|
||||||
|
fmt.Println(resp.GetHttpContentString())
|
||||||
|
fmt.Println(resp.GetHttpHeaders())
|
||||||
|
}
|
37
services/www/get_pwd.go
Normal file
37
services/www/get_pwd.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package www
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPwdRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
UserName string `position:"Query" field:"user_name" default:"-" `
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPwdResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Ret int `json:"ret"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct {
|
||||||
|
UserName string `json:"user_name"`
|
||||||
|
UserPwd string `json:"user_pwd"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetPwdRequest() (req *GetPwdRequest) {
|
||||||
|
req = &GetPwdRequest{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/limit/getPwd.php")
|
||||||
|
req.Method = requests.GET
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetPwdResponse() (response *GetPwdResponse) {
|
||||||
|
response = &GetPwdResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
1
services/www/get_token.go
Normal file
1
services/www/get_token.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package www
|
Loading…
Reference in New Issue
Block a user