Skip to content

Commit

Permalink
Fix for local html override, where assigning a wrong path makes the w…
Browse files Browse the repository at this point in the history
…ebservice use neither the built in nor the local files
  • Loading branch information
lkarlslund committed Nov 22, 2021
1 parent b472b3e commit 703b988
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions modules/analyze/webservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,8 @@ func webservice(bind string, quit chan bool, objs *engine.Objects) (*http.Server
})

// Serve embedded static files, or from html folder if it exists
if *localhtml == "" {
router.PathPrefix("/").Handler(http.FileServer(http.FS(FSPrefix{
Prefix: "html",
FS: embeddedassets,
})))
} else {
var usinglocalhtml bool
if *localhtml != "" {
// Override embedded HTML if asked to
if stat, err := os.Stat(*localhtml); err == nil && stat.IsDir() {
// Use local files if they exist
Expand All @@ -948,10 +944,17 @@ func webservice(bind string, quit chan bool, objs *engine.Objects) (*http.Server
FS: assets,
})))
}
usinglocalhtml = true
} else {
log.Warn().Msgf("Not switching from embedded HTML to local folder %v, failure: %v", *localhtml, err)
}
}
if !usinglocalhtml {
router.PathPrefix("/").Handler(http.FileServer(http.FS(FSPrefix{
Prefix: "html",
FS: embeddedassets,
})))
}

log.Info().Msgf("Listening - navigate to %v ... (ctrl-c or similar to quit)", bind)

Expand Down

0 comments on commit 703b988

Please sign in to comment.