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 (
key = []byte(securecookie.GenerateRandomKey(32))
store = sessions.NewCookieStore(key)
conf = config.LoadedConfig()
store *sessions.CookieStore
conf *config.Config
)
func init() {
func statsInitialize(c *config.Config) {
key := []byte(securecookie.GenerateRandomKey(32))
store = sessions.NewCookieStore(key)
store.Options = &sessions.Options{
Path: conf.BaseURL+"/stats",
Path: c.BaseURL + "/stats",
MaxAge: 3600 * 1, // 1 hour
HttpOnly: true,
SameSite: http.SameSiteStrictMode,
}
conf = c
}
func Stats(w http.ResponseWriter, r *http.Request) {

View File

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