Skip to content

Commit

Permalink
chore: save context on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
alonkeyval committed Jun 27, 2024
1 parent 841a5d0 commit 3df38c5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,21 @@ func startHTTPServer(flags *Flags) (*gin.Engine, error) {

func httpFileServerWith404(fs http.FileSystem) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := fs.Open(r.URL.Path)
filePath := r.URL.Path

// Check if the file exists
_, err := fs.Open(filePath)
if err != nil {
// Serve index.html
r.URL.Path = "/"
// Try appending .html to the path and check again
filePath += ".html"
_, err = fs.Open(filePath)
if err != nil {
// If file does not exist, serve index.html
filePath = "/index.html"
}
}
http.FileServer(fs).ServeHTTP(w, r)

http.ServeFile(w, r, "webapp/out"+filePath)
})
}

Expand Down Expand Up @@ -202,13 +211,13 @@ func main() {
log.Println("Starting Odigos UI...")
log.Printf("Odigos UI is available at: http://%s:%d", flags.Address, flags.Port)

go func () {
go func() {
err = r.Run(fmt.Sprintf("%s:%d", flags.Address, flags.Port))
if err != nil {
log.Fatalf("Error starting server: %s", err)
}
} ()
}()

<- ch
<-ch
log.Println("Shutting down Odigos UI...")
}

0 comments on commit 3df38c5

Please sign in to comment.