kefu/middleware/language.go

19 lines
270 B
Go
Raw Normal View History

2024-12-10 02:50:12 +00:00
package middleware
import (
"github.com/gin-gonic/gin"
"kefu/types"
)
func SetLanguage(c *gin.Context) {
lang := c.Query("lang")
if lang == "" {
lang = c.GetHeader("lang")
if lang == "" {
lang = "cn"
}
}
types.ApiCode.LANG = lang
c.Set("lang", lang)
}