@@ -8,30 +8,30 @@ import (
8
8
)
9
9
10
10
const (
11
- scheduleDebug = false
12
- scheduleCacheControl = "public, max-age=5"
11
+ ScheduleDebug = false
12
+ ScheduleCacheControl = "public, max-age=5"
13
13
)
14
14
15
15
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 )
20
19
return
21
20
}
22
21
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 )
26
26
return
27
27
}
28
28
29
29
if cached , b := svc .Cache .Get ("schedule" ); b {
30
- c .Header ("Cache-Control" , scheduleCacheControl )
30
+ c .Header ("Cache-Control" , ScheduleCacheControl )
31
31
c .Data (200 , "application/json" , cached .([]byte ))
32
32
return
33
33
}
34
34
35
- c .Header ("Cache-Control" , scheduleCacheControl )
35
+ c .Header ("Cache-Control" , ScheduleCacheControl )
36
36
c .JSON (500 , gin.H {"code" : - 1 , "msg" : "Failed to get schedule" })
37
37
}
0 commit comments