We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 36b5481 commit 2dbe594Copy full SHA for 2dbe594
1 file changed
internal/base/handler/short_id.go
@@ -23,10 +23,22 @@ import (
23
"context"
24
25
"github.com/apache/answer/internal/base/constant"
26
+ "github.com/gin-gonic/gin"
27
)
28
-// GetEnableShortID get language from header
29
+// GetEnableShortID get short id flag from context
30
func 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)
42
flag, ok := ctx.Value(constant.ShortIDContextKey).(bool)
43
if ok {
44
return flag
0 commit comments