
Reviewed-on: #1 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
27 lines
530 B
Go
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))
|
|
}
|