settoken.go 722 B

1234567891011121314151617181920212223242526272829
  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. "strings"
  12. )
  13. // SetToken 设置调试token
  14. func SetToken(c *gin.Context) {
  15. host := c.Request.Host
  16. if strings.Contains(host, `192.168.`) || strings.Contains(host, `localhost`) {
  17. if cli := rediscli.GetRedisClient(); cli != nil {
  18. _ = cli.HSet("\"monitor:online_loginid:778899:1\"", "Token", "778899_123456_1")
  19. c.String(http.StatusOK, `设置成功!(仅当内网且调试模式下才可设置), token:778899_123456_1`)
  20. } else {
  21. c.String(http.StatusOK, "not connect redis")
  22. }
  23. } else {
  24. c.String(http.StatusOK, "not support!")
  25. }
  26. }