mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 11:11:03 +01:00
21 lines
504 B
Go
21 lines
504 B
Go
|
package client
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
"time"
|
||
|
|
||
|
"github.com/kataras/iris/cache/entry"
|
||
|
)
|
||
|
|
||
|
// GetMaxAge parses the "Cache-Control" header
|
||
|
// and returns a LifeChanger which can be passed
|
||
|
// to the response's Reset
|
||
|
func GetMaxAge(r *http.Request) entry.LifeChanger {
|
||
|
return func() time.Duration {
|
||
|
cacheControlHeader := r.Header.Get("Cache-Control")
|
||
|
// headerCacheDur returns the seconds
|
||
|
headerCacheDur := entry.ParseMaxAge(cacheControlHeader)
|
||
|
return time.Duration(headerCacheDur) * time.Second
|
||
|
}
|
||
|
}
|