Skip to content

Commit abe72e3

Browse files
committed
refactor: schedule cache control constants to public
1 parent db09de9 commit abe72e3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

internal/handler/schedule.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ import (
88
)
99

1010
const (
11-
scheduleDebug = false
12-
scheduleCacheControl = "public, max-age=5"
11+
ScheduleDebug = false
12+
ScheduleCacheControl = "public, max-age=5"
1313
)
1414

1515
func ScheduleHandler(c *gin.Context) {
16-
// 是否存在 Tencent-Acceleration-Domain-Name
17-
if c.GetHeader("Tencent-Acceleration-Domain-Name") != "" {
18-
c.Header("Cache-Control", scheduleCacheControl)
19-
c.Redirect(301, job.ScheduleUrl)
16+
if ScheduleDebug {
17+
c.Header("Cache-Control", "no-cache")
18+
c.Data(200, "application/json", static.ScheduleBytes)
2019
return
2120
}
2221

23-
if scheduleDebug {
24-
c.Header("Cache-Control", "no-cache")
25-
c.Data(200, "application/json", static.ScheduleBytes)
22+
// 是否存在 Tencent-Acceleration-Domain-Name
23+
if c.GetHeader("Tencent-Acceleration-Domain-Name") != "" {
24+
c.Header("Cache-Control", ScheduleCacheControl)
25+
c.Redirect(301, job.ScheduleUrl)
2626
return
2727
}
2828

2929
if cached, b := svc.Cache.Get("schedule"); b {
30-
c.Header("Cache-Control", scheduleCacheControl)
30+
c.Header("Cache-Control", ScheduleCacheControl)
3131
c.Data(200, "application/json", cached.([]byte))
3232
return
3333
}
3434

35-
c.Header("Cache-Control", scheduleCacheControl)
35+
c.Header("Cache-Control", ScheduleCacheControl)
3636
c.JSON(500, gin.H{"code": -1, "msg": "Failed to get schedule"})
3737
}

0 commit comments

Comments
 (0)