settoken.go 719 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/10/27 10:22
  4. * @Modify : 2021/10/27 10:22
  5. */
  6. package other
  7. import (
  8. "github.com/gin-gonic/gin"
  9. "mtp2_if/rediscli"
  10. "net/http"
  11. )
  12. // SetToken 设置调试token
  13. func SetToken(c *gin.Context) {
  14. //host := c.Request.Host
  15. if true /*strings.Contains(host, `192.168.`) || strings.Contains(host, `localhost`) */ {
  16. if cli := rediscli.GetRedisClient(); cli != nil {
  17. _ = cli.HSet("monitor:online_loginid:778899:1", "Token", "778899_123456_1")
  18. c.String(http.StatusOK, `设置成功!(仅当内网且调试模式下才可设置), token:778899_123456_1`)
  19. } else {
  20. c.String(http.StatusOK, "not connect redis")
  21. }
  22. } else {
  23. c.String(http.StatusOK, "not support!")
  24. }
  25. }