MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / DelUserCacheOnline

Function DelUserCacheOnline

cmd/user.go:24–52  ·  view source on GitHub ↗
(username string)

Source from the content-addressed store, hash-verified

22}
23
24func 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}

Callers 1

DelAdminCacheOnlineFunction · 0.85

Calls 6

GetStrFunction · 0.92
SetTimeoutMethod · 0.80
PostMethod · 0.80
SetHeaderMethod · 0.80
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected