Add X-Cache-Hit header
This commit is contained in:
@@ -49,7 +49,7 @@ func init() {
|
|||||||
app.Use(cors.New(cors.Config{
|
app.Use(cors.New(cors.Config{
|
||||||
AllowOrigins: "*",
|
AllowOrigins: "*",
|
||||||
AllowMethods: "HEAD,OPTIONS,GET",
|
AllowMethods: "HEAD,OPTIONS,GET",
|
||||||
ExposeHeaders: "X-Cache-Time-Remaining",
|
ExposeHeaders: "X-Cache-Hit,X-Cache-Time-Remaining",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
app.Use(logger.New(logger.Config{
|
app.Use(logger.New(logger.Config{
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ func JavaStatusHandler(ctx *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Set("X-Cache-Hit", strconv.FormatBool(expiresAt != nil))
|
||||||
|
|
||||||
if expiresAt != nil {
|
if expiresAt != nil {
|
||||||
ctx.Set("X-Cache-Time-Remaining", strconv.Itoa(int(expiresAt.Seconds())))
|
ctx.Set("X-Cache-Time-Remaining", strconv.Itoa(int(expiresAt.Seconds())))
|
||||||
}
|
}
|
||||||
@@ -62,6 +64,8 @@ func BedrockStatusHandler(ctx *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Set("X-Cache-Hit", strconv.FormatBool(expiresAt != nil))
|
||||||
|
|
||||||
if expiresAt != nil {
|
if expiresAt != nil {
|
||||||
ctx.Set("X-Cache-Time-Remaining", strconv.Itoa(int(expiresAt.Seconds())))
|
ctx.Set("X-Cache-Time-Remaining", strconv.Itoa(int(expiresAt.Seconds())))
|
||||||
}
|
}
|
||||||
@@ -82,6 +86,8 @@ func IconHandler(ctx *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Set("X-Cache-Hit", strconv.FormatBool(expiresAt != nil))
|
||||||
|
|
||||||
if expiresAt != nil {
|
if expiresAt != nil {
|
||||||
ctx.Set("X-Cache-Time-Remaining", strconv.Itoa(int(expiresAt.Seconds())))
|
ctx.Set("X-Cache-Time-Remaining", strconv.Itoa(int(expiresAt.Seconds())))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user