Fix docsite path error in docsite.go (#1272)

The docsite path was being initialized as a global variable. This wasn't
an issue before we were caching and unsetting the env vars, but now that
`wavebase.GetWaveAppPath()` returns the contents of the cached variable,
we need to read its value at runtime, since it won't be set at the time
the global variable is initialized.
This commit is contained in:
Evan Simkowitz 2024-11-12 12:30:37 -08:00 committed by GitHub
parent 6021ef0fd6
commit 6216dca17a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

2
.gitignore vendored
View File

@ -30,3 +30,5 @@ artifacts/
storybook-static/ storybook-static/
test-results.xml test-results.xml
docsite/

View File

@ -9,11 +9,10 @@ import (
"github.com/wavetermdev/waveterm/pkg/wavebase" "github.com/wavetermdev/waveterm/pkg/wavebase"
) )
var docsiteStaticPath = filepath.Join(wavebase.GetWaveAppPath(), "docsite")
var docsiteHandler http.Handler var docsiteHandler http.Handler
func GetDocsiteHandler() http.Handler { func GetDocsiteHandler() http.Handler {
docsiteStaticPath := filepath.Join(wavebase.GetWaveAppPath(), "docsite")
stat, err := os.Stat(docsiteStaticPath) stat, err := os.Stat(docsiteStaticPath)
if docsiteHandler == nil { if docsiteHandler == nil {
log.Println("Docsite is nil, initializing") log.Println("Docsite is nil, initializing")
@ -21,7 +20,7 @@ func GetDocsiteHandler() http.Handler {
log.Printf("Found static site at %s, serving\n", docsiteStaticPath) log.Printf("Found static site at %s, serving\n", docsiteStaticPath)
docsiteHandler = http.FileServer(HTMLDir{http.Dir(docsiteStaticPath)}) docsiteHandler = http.FileServer(HTMLDir{http.Dir(docsiteStaticPath)})
} else { } else {
log.Println("Did not find static site, serving not found handler") log.Printf("Did not find static site at %s, serving not found handler. stat: %v, err: %v\n", docsiteStaticPath, stat, err)
docsiteHandler = http.NotFoundHandler() docsiteHandler = http.NotFoundHandler()
} }
} }