Files
top-wallpaper/http/handler.go
Ron Rise ff66877192
All checks were successful
🚨 Test Code Base / 🔍 🐹 Go Tests (push) Successful in 1m22s
🚨 Test Code Base / 🧹 Lint (push) Successful in 1m31s
🏗️✨ Build Workflow / 🖥️ 🔨 Build (push) Successful in 11m11s
update-deps (#1)
Reviewed-on: #1
Co-authored-by: Ron Rise <ron@siteworxpro.com>
Co-committed-by: Ron Rise <ron@siteworxpro.com>
2025-08-26 16:36:17 +00:00

27 lines
530 B
Go

package http
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/siteworxpro/top-wallpaper/redis"
)
func Get(c echo.Context) error {
rc, err := redis.NewRedis()
if err != nil {
return c.String(http.StatusInternalServerError, "Internal Server Error: "+err.Error())
}
val, err := rc.Get(redis.CacheKey)
if err != nil || val == "" {
return c.NoContent(http.StatusNoContent)
}
c.Response().Header().Set("Cache-Control", "public, max-age=600")
return c.Blob(http.StatusOK, "image/jpeg", []byte(val))
}