File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,22 @@ import (
2323 "context"
2424
2525 "github.com/apache/answer/internal/base/constant"
26+ "github.com/gin-gonic/gin"
2627)
2728
28- // GetEnableShortID get language from header
29+ // GetEnableShortID get short id flag from context
2930func GetEnableShortID (ctx context.Context ) bool {
31+ // Check gin context first (set by ShortIDMiddleware via ctx.Set)
32+ if ginCtx , ok := ctx .(* gin.Context ); ok {
33+ flag , ok := ginCtx .Get (constant .ShortIDFlag )
34+ if ok {
35+ if flag , ok := flag .(bool ); ok {
36+ return flag
37+ }
38+ return false
39+ }
40+ }
41+ // Fallback for non-gin contexts (e.g., SitemapCron uses context.WithValue)
3042 flag , ok := ctx .Value (constant .ShortIDContextKey ).(bool )
3143 if ok {
3244 return flag
You can’t perform that action at this time.
0 commit comments