You've already forked top-wallpaper
Refactor caching logic and add support for a new feature
This commit is contained in:
@@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/siteworxpro/top-wallpaper/redis"
|
||||
@@ -14,7 +15,10 @@ func Get(c echo.Context) error {
|
||||
return c.String(http.StatusInternalServerError, "Internal Server Error: "+err.Error())
|
||||
}
|
||||
|
||||
val, err := rc.Get(redis.CacheKey)
|
||||
defer rc.Close()
|
||||
|
||||
nsfw := (c.QueryParam("nsfw") == "true" || c.QueryParam("nsfw") == "1") && os.Getenv("NSFW_MODE") == "true"
|
||||
val, err := rc.Get(rc.GetCacheKey(nsfw))
|
||||
|
||||
if err != nil || val == "" {
|
||||
return c.NoContent(http.StatusNoContent)
|
||||
|
||||
Reference in New Issue
Block a user