Archived
Template
1
0

Various fixes (#5)

* Fixes #1

* Fixes #2

* Fixes #3

* Fixes #4
This commit is contained in:
Markus Tenghamn
2021-12-13 20:33:50 +01:00
committed by GitHub
parent c2493c238f
commit b5ba3d0387
234 changed files with 872 additions and 58627 deletions

11
env.go
View File

@ -1,6 +1,7 @@
package baseproject
import (
"github.com/gorilla/securecookie"
"github.com/uberswe/golang-base-project/config"
"github.com/uberswe/golang-base-project/util"
"log"
@ -19,8 +20,8 @@ func loadEnvVariables() (c config.Config) {
c.BaseURL = os.Getenv("BASE_URL")
}
// A random secret will be generated when the application starts if no secret is provided. It is highly recommended to provide a secret.
c.CookieSecret = util.GenerateULID()
// A random secret will be generated when the application starts if no secret is provided. It is highly recommended providing a secret.
c.CookieSecret = string(securecookie.GenerateRandomKey(64))
if os.Getenv("COOKIE_SECRET") != "" {
c.CookieSecret = os.Getenv("COOKIE_SECRET")
}
@ -70,5 +71,11 @@ func loadEnvVariables() (c config.Config) {
}
c.RequestsPerMinute = i
}
// CacheParameter is added to the end of static file urls to prevent caching old versions
c.CacheParameter = util.RandomString(10)
if os.Getenv("CACHE_PARAMETER") != "" {
c.CacheParameter = os.Getenv("CACHE_PARAMETER")
}
return c
}