mirror of
https://github.com/wahyd4/badger.git
synced 2026-08-09 05:15:58 +10:00
Force badge cache to expire in 120 seconds
This commit is contained in:
@@ -21,13 +21,14 @@ import (
|
||||
|
||||
const (
|
||||
// backgroundImageFilename = "images/bg.png"
|
||||
radius = 0
|
||||
fontSize = 12
|
||||
textMarginX = 5.0
|
||||
textMarginY = -2.0
|
||||
badgeWidth = 180
|
||||
badgeHeight = 20
|
||||
textStyle = "text-anchor:right;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;"
|
||||
radius = 0
|
||||
fontSize = 12
|
||||
textMarginX = 5.0
|
||||
textMarginY = -2.0
|
||||
badgeWidth = 180
|
||||
badgeHeight = 20
|
||||
textStyle = "text-anchor:right;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;"
|
||||
badgeExpireSeconds = 120
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -94,6 +95,7 @@ func geneateSvg(client api.Client, c *gin.Context) error {
|
||||
|
||||
w := c.Writer
|
||||
w.Header().Set("Content-Type", "image/svg+xml")
|
||||
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, s-maxage=%d", badgeExpireSeconds, badgeExpireSeconds))
|
||||
canvas := svg.New(w)
|
||||
canvas.Start(badgeWidth, badgeHeight)
|
||||
canvas.Rect(0, 0, badgeWidth, badgeHeight, "fill-opacity:1.00; fill:rgb(90,90,90)")
|
||||
@@ -157,6 +159,7 @@ func generateBadge(client api.Client, c *gin.Context) error {
|
||||
w := c.Writer
|
||||
c.Status(http.StatusOK)
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, s-maxage=%d", badgeExpireSeconds, badgeExpireSeconds))
|
||||
return dc.EncodePNG(w)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user