Fix initialization of conf for stats

This commit is contained in:
Balakrishnan Balasubramanian 2023-05-09 22:05:03 -04:00
parent 7001fa4fa5
commit 8ce11fa824
2 changed files with 8 additions and 5 deletions

View File

@ -21,18 +21,20 @@ type StatsData struct {
} }
var ( var (
key = []byte(securecookie.GenerateRandomKey(32)) store *sessions.CookieStore
store = sessions.NewCookieStore(key) conf *config.Config
conf = config.LoadedConfig()
) )
func init() { func statsInitialize(c *config.Config) {
key := []byte(securecookie.GenerateRandomKey(32))
store = sessions.NewCookieStore(key)
store.Options = &sessions.Options{ store.Options = &sessions.Options{
Path: conf.BaseURL+"/stats", Path: c.BaseURL + "/stats",
MaxAge: 3600 * 1, // 1 hour MaxAge: 3600 * 1, // 1 hour
HttpOnly: true, HttpOnly: true,
SameSite: http.SameSiteStrictMode, SameSite: http.SameSiteStrictMode,
} }
conf = c
} }
func Stats(w http.ResponseWriter, r *http.Request) { func Stats(w http.ResponseWriter, r *http.Request) {

View File

@ -87,6 +87,7 @@ type IPInfoResponse struct {
} }
func Initialize(c *config.Config) { func Initialize(c *config.Config) {
statsInitialize(c)
// changed to use Noto Sans instead of OpenSans, due to issue: // changed to use Noto Sans instead of OpenSans, due to issue:
// https://github.com/golang/freetype/issues/8 // https://github.com/golang/freetype/issues/8
fLight, err := freetype.ParseFont(fontLightBytes) fLight, err := freetype.ParseFont(fontLightBytes)