(username string)
| 22 | } |
| 23 | |
| 24 | func DelUserCacheOnline(username string) { |
| 25 | client := resty.New().SetTimeout(1 * time.Second).SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify}) |
| 26 | token := setting.GetStr(conf.Token) |
| 27 | port := conf.Conf.Scheme.HttpPort |
| 28 | u := fmt.Sprintf("http://localhost:%d/api/admin/user/del_cache", port) |
| 29 | if port == -1 { |
| 30 | if conf.Conf.Scheme.HttpsPort == -1 { |
| 31 | utils.Log.Warnf("[del_user_cache] no open port") |
| 32 | return |
| 33 | } |
| 34 | u = fmt.Sprintf("https://localhost:%d/api/admin/user/del_cache", conf.Conf.Scheme.HttpsPort) |
| 35 | } |
| 36 | res, err := client.R().SetHeader("Authorization", token).SetQueryParam("username", username).Post(u) |
| 37 | if err != nil { |
| 38 | utils.Log.Warnf("[del_user_cache_online] failed: %+v", err) |
| 39 | return |
| 40 | } |
| 41 | if res.StatusCode() != 200 { |
| 42 | utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String()) |
| 43 | return |
| 44 | } |
| 45 | code := utils.Json.Get(res.Body(), "code").ToInt() |
| 46 | msg := utils.Json.Get(res.Body(), "message").ToString() |
| 47 | if code != 200 { |
| 48 | utils.Log.Errorf("[del_user_cache_online] error: %s", msg) |
| 49 | return |
| 50 | } |
| 51 | utils.Log.Debugf("[del_user_cache_online] del user [%s] cache success", username) |
| 52 | } |
no test coverage detected