Skip to content

Commit

Permalink
Fix docsite path error in docsite.go (#1272)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
esimkowitz authored Nov 12, 2024
1 parent 6021ef0 commit 6216dca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ artifacts/
storybook-static/

test-results.xml

docsite/
5 changes: 2 additions & 3 deletions pkg/docsite/docsite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ import (
"github.com/wavetermdev/waveterm/pkg/wavebase"
)

var docsiteStaticPath = filepath.Join(wavebase.GetWaveAppPath(), "docsite")

var docsiteHandler http.Handler

func GetDocsiteHandler() http.Handler {
docsiteStaticPath := filepath.Join(wavebase.GetWaveAppPath(), "docsite")
stat, err := os.Stat(docsiteStaticPath)
if docsiteHandler == nil {
log.Println("Docsite is nil, initializing")
if err == nil && stat.IsDir() {
log.Printf("Found static site at %s, serving\n", docsiteStaticPath)
docsiteHandler = http.FileServer(HTMLDir{http.Dir(docsiteStaticPath)})
} 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()
}
}
Expand Down

0 comments on commit 6216dca

Please sign in to comment.