1. TODO: guest_id 2. jwt的封装
This commit is contained in:
@@ -42,11 +42,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/user/basic-info",
|
||||
Handler: UserBasicInfoHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/user/address-list",
|
||||
Handler: UserAddressListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/474420502/requests"
|
||||
)
|
||||
|
||||
func TestCaseAddressList(t *testing.T) {
|
||||
|
||||
// http.NewRequest("POST", "http://localhost:8888/user/login", body io.Reader)
|
||||
|
||||
ses := requests.NewSession()
|
||||
tp := ses.Post("http://localhost:8888/user/login")
|
||||
resp, err := tp.SetBodyJson(map[string]interface{}{
|
||||
"name": "devenv@sina.cn",
|
||||
"pwd": "$2y$13$6UFDMZQMEfqFYiNLpiUCi.B3fpvGEamPAjIgzUqv/u7jT05nB3pOC",
|
||||
}).Execute()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
result := resp.Json()
|
||||
token := result.Get("data.token")
|
||||
ses.Header.Add("Authorization", token.String())
|
||||
log.Println(string(resp.Content()))
|
||||
|
||||
resp, err = ses.Get("http://localhost:8888/user/address-list").Execute()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Println(string(resp.Content()))
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user