diff --git a/evo.context.go b/evo.context.go index a11a40b4..af5dfbeb 100644 --- a/evo.context.go +++ b/evo.context.go @@ -258,10 +258,6 @@ func (r *Request) RestartRouting() error { } func (r *Request) SetCacheControl(t time.Duration, headers ...string) { - if len(headers) == 0 { - return - } - var ccHeader string = fmt.Sprintf("max-age=%.0f", t.Seconds()) var options string diff --git a/lib/outcome/outcome.go b/lib/outcome/outcome.go index d191c685..5695703e 100644 --- a/lib/outcome/outcome.go +++ b/lib/outcome/outcome.go @@ -4,9 +4,10 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/gofiber/fiber/v2" "reflect" "time" + + "github.com/gofiber/fiber/v2" ) type Response struct { @@ -185,3 +186,21 @@ func (response *Response) Filename(filename string) *Response { func (response *Response) ResponseSerializer() *Response { return response } + +func (response *Response) SetCacheControl(t time.Duration, headers ...string) *Response { + var ccHeader string = fmt.Sprintf("max-age=%.0f", t.Seconds()) + var options string + + for _, header := range headers { + options = options + fmt.Sprintf(", %s", header) + } + + ccHeader = ccHeader + options + + if response.Headers == nil { + response.Headers = map[string]string{} + } + response.Headers["Cache-Control"] = ccHeader + + return response +}