package auth import ( "net/http" "time" xhttp "github.com/zeromicro/x/http" "tianyuan-api/apps/gateway/internal/svc" ) func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // 设置空的JWT Cookie,覆盖之前的JWT http.SetCookie(w, &http.Cookie{ Name: "Authorization", // 你的JWT cookie名 Value: "", // 清空cookies Path: "/", HttpOnly: true, Expires: time.Unix(0, 0), // 过期时间设置为过去 }) xhttp.JsonBaseResponseCtx(r.Context(), w, nil) } }