header加token
This commit is contained in:
parent
ccf1916e4e
commit
af83caeaa4
5
main.go
5
main.go
|
|
@ -105,11 +105,6 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||||
if tokenString == "" {
|
if tokenString == "" {
|
||||||
tokenString = c.Query("token")
|
tokenString = c.Query("token")
|
||||||
}
|
}
|
||||||
//测试
|
|
||||||
if strings.Contains(c.Request.URL.Path, "/shell/") {
|
|
||||||
log.Printf("req token:%s ,path:%s", tokenString, c.Request.URL.Path)
|
|
||||||
}
|
|
||||||
|
|
||||||
//如果请求为login或register,则不需要验证token
|
//如果请求为login或register,则不需要验证token
|
||||||
for k, _ := range proto.Url_map {
|
for k, _ := range proto.Url_map {
|
||||||
if strings.Contains(c.Request.URL.Path, k) {
|
if strings.Contains(c.Request.URL.Path, k) {
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ func SyncDataFromMasterShellReq2(url string, data proto.SyncUserShellReq) ([]dao
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("token", data.Token)
|
||||||
//传输数据
|
//传输数据
|
||||||
if client == nil {
|
if client == nil {
|
||||||
client = &http.Client{}
|
client = &http.Client{}
|
||||||
|
|
@ -254,6 +255,7 @@ func SyncDataFromMasterShellReq3(url string, data proto.SyncUserShellResp) ([]pr
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("token", data.Token)
|
||||||
//传输数据
|
//传输数据
|
||||||
if client == nil {
|
if client == nil {
|
||||||
client = &http.Client{}
|
client = &http.Client{}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue