mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-06-05 23:03:48 +00:00
Add ability to set cache via query header.
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
fiber "github.com/gofiber/fiber/v2"
|
||||
@@ -124,6 +125,15 @@ func processGraphQLRequest(c *fiber.Ctx) error {
|
||||
cache_time = cfg.Cache.CacheTTL
|
||||
}
|
||||
|
||||
if cache_time == 0 && !cacheFromQuery {
|
||||
cacheQuery := c.Request().Header.Peek("X-Cache-Graphql-Query")
|
||||
if cacheQuery != nil {
|
||||
cache_time, _ = strconv.Atoi(string(cacheQuery))
|
||||
cfg.Logger.Debug("Cache time set via header", map[string]interface{}{"cache_time": cache_time})
|
||||
cacheFromQuery = true
|
||||
}
|
||||
}
|
||||
|
||||
wasCached := false
|
||||
|
||||
// Handling Cache Logic
|
||||
|
||||
Reference in New Issue
Block a user