From f2023a7af25170dfcfb31ef742c82e15e8171d38 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 1 Dec 2021 20:35:28 +0100 Subject: [PATCH] *: don't use go embed to make using custom files easier Signed-off-by: Jens Langhammer --- internal/outpost/proxyv2/handlers.go | 3 +-- internal/web/static.go | 23 ++++------------------- web/static.go | 8 +------- website/static.go | 6 ------ 4 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 website/static.go diff --git a/internal/outpost/proxyv2/handlers.go b/internal/outpost/proxyv2/handlers.go index 95045cc9c..8e1209473 100644 --- a/internal/outpost/proxyv2/handlers.go +++ b/internal/outpost/proxyv2/handlers.go @@ -10,7 +10,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "goauthentik.io/internal/outpost/proxyv2/metrics" "goauthentik.io/internal/utils/web" - staticWeb "goauthentik.io/web" ) func (ps *ProxyServer) HandlePing(rw http.ResponseWriter, r *http.Request) { @@ -29,7 +28,7 @@ func (ps *ProxyServer) HandlePing(rw http.ResponseWriter, r *http.Request) { } func (ps *ProxyServer) HandleStatic(rw http.ResponseWriter, r *http.Request) { - staticFs := http.FileServer(http.FS(staticWeb.StaticDist)) + staticFs := http.FileServer(http.Dir("./website/static/")) before := time.Now() web.DisableIndex(http.StripPrefix("/akprox/static", staticFs)).ServeHTTP(rw, r) after := time.Since(before) diff --git a/internal/web/static.go b/internal/web/static.go index 0cb034696..9b47b2d61 100644 --- a/internal/web/static.go +++ b/internal/web/static.go @@ -9,7 +9,6 @@ import ( "goauthentik.io/internal/constants" "goauthentik.io/internal/utils/web" staticWeb "goauthentik.io/web" - staticDocs "goauthentik.io/website" ) func (ws *WebServer) configureStatic() { @@ -18,24 +17,10 @@ func (ws *WebServer) configureStatic() { indexLessRouter.Use(web.DisableIndex) // Media files, always local fs := http.FileServer(http.Dir(config.G.Paths.Media)) - var distHandler http.Handler - var distFs http.Handler - var authentikHandler http.Handler - var helpHandler http.Handler - if config.G.Debug || config.G.Web.LoadLocalFiles { - ws.log.Debug("Using local static files") - distFs = http.FileServer(http.Dir("./web/dist")) - distHandler = http.StripPrefix("/static/dist/", distFs) - authentikHandler = http.StripPrefix("/static/authentik/", http.FileServer(http.Dir("./web/authentik"))) - helpHandler = http.FileServer(http.Dir("./website/help/")) - } else { - statRouter.Use(ws.staticHeaderMiddleware) - ws.log.Debug("Using packaged static files with aggressive caching") - distFs = http.FileServer(http.FS(staticWeb.StaticDist)) - distHandler = http.StripPrefix("/static", distFs) - authentikHandler = http.StripPrefix("/static", http.FileServer(http.FS(staticWeb.StaticAuthentik))) - helpHandler = http.FileServer(http.FS(staticDocs.Help)) - } + distFs := http.FileServer(http.Dir("./web/dist")) + distHandler := http.StripPrefix("/static/dist/", distFs) + authentikHandler := http.StripPrefix("/static/authentik/", http.FileServer(http.Dir("./web/authentik"))) + helpHandler := http.FileServer(http.Dir("./website/help/")) indexLessRouter.PathPrefix("/static/dist/").Handler(distHandler) indexLessRouter.PathPrefix("/static/authentik/").Handler(authentikHandler) diff --git a/web/static.go b/web/static.go index 44ce69706..77934988b 100644 --- a/web/static.go +++ b/web/static.go @@ -1,12 +1,6 @@ package web -import "embed" - -//go:embed dist/* -var StaticDist embed.FS - -//go:embed authentik -var StaticAuthentik embed.FS +import _ "embed" //go:embed robots.txt var RobotsTxt []byte diff --git a/website/static.go b/website/static.go deleted file mode 100644 index 1c44b1d66..000000000 --- a/website/static.go +++ /dev/null @@ -1,6 +0,0 @@ -package web - -import "embed" - -//go:embed help/* -var Help embed.FS