mirror of
https://github.com/Kugelschieber/schnittfest.git
synced 2026-01-18 02:10:27 +00:00
Fixed static content path and made content caching optional.
This commit is contained in:
11
main.go
11
main.go
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
staticDir = "public/static"
|
||||
staticDir = "static"
|
||||
staticDirPrefix = "/static/"
|
||||
envPrefix = "SCHNITTFEST_"
|
||||
pwdString = "PASSWORD" // do not log passwords!
|
||||
@@ -23,6 +23,10 @@ const (
|
||||
defaultHttpReadTimeout = 20
|
||||
)
|
||||
|
||||
var (
|
||||
disableCache = strings.ToLower(os.Getenv("SCHNITTFEST_DISABLE_CACHE")) == "true"
|
||||
)
|
||||
|
||||
func configureLog() {
|
||||
logbuch.Info("Configure logging...")
|
||||
logbuch.SetFormatter(logbuch.NewFieldFormatter("", "\t"))
|
||||
@@ -52,7 +56,10 @@ func setupRouter() *mux.Router {
|
||||
// static content
|
||||
fs := http.StripPrefix(staticDirPrefix, http.FileServer(http.Dir(staticDir)))
|
||||
router.PathPrefix(staticDirPrefix).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Cache-Control", "max-age=3600")
|
||||
if !disableCache {
|
||||
w.Header().Add("Cache-Control", "max-age=3600")
|
||||
}
|
||||
|
||||
fs.ServeHTTP(w, r)
|
||||
}).Methods("GET")
|
||||
|
||||
|
||||
@@ -2,5 +2,6 @@ set SCHNITTFEST_HOST=localhost:8080
|
||||
set SCHNITTFEST_LOGLEVEL=debug
|
||||
set SCHNITTFEST_ALLOWED_ORIGINS=*
|
||||
set SCHNITTFEST_TLS_ENABLE=false
|
||||
set SCHNITTFEST_DISABLE_CACHE=true
|
||||
|
||||
go run main.go
|
||||
|
||||
@@ -4,5 +4,6 @@ export SCHNITTFEST_HOST=localhost:8080
|
||||
export SCHNITTFEST_LOGLEVEL=debug
|
||||
export SCHNITTFEST_ALLOWED_ORIGINS=*
|
||||
export SCHNITTFEST_TLS_ENABLE=false
|
||||
export SCHNITTFEST_DISABLE_CACHE=true
|
||||
|
||||
go run main.go
|
||||
|
||||
@@ -1 +1 @@
|
||||
html,body{font-family:sans-serif}
|
||||
html,body{font-family:sans-serif;font-size:40px}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
html, body {
|
||||
font-family: sans-serif;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user