Skip to content

Commit

Permalink
Add generated frontend from frontend repo
Browse files Browse the repository at this point in the history
  • Loading branch information
wendevlin committed Oct 30, 2024
1 parent 67abf8b commit 1f8c3b2
Show file tree
Hide file tree
Showing 211 changed files with 778 additions and 2,025 deletions.
32 changes: 17 additions & 15 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
"containerEnv": {
"DEVELOPMENT": "True"
},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.useGoProxyToCheckForToolUpdates": false,
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go",
"go.toolsGopath": "/go/bin",
"go.lintTool":"golangci-lint",
"go.lintFlags": [
"--fast"
]
},
"extensions": [
"golang.Go"
]
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.useGoProxyToCheckForToolUpdates": false,
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go",
"go.toolsGopath": "/go/bin",
"go.lintTool":"golangci-lint",
"go.lintFlags": [
"--fast"
]
},
"extensions": ["golang.Go"]
}
}
}
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
go = "latest"
18 changes: 16 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ func httpSupervisorProxy(w http.ResponseWriter, r *http.Request) {
log.Printf("Proxy request: %s", r.URL.Path)

// Base Supervisor URL
u, err := url.Parse("http://supervisor/")
supervisorHost := "supervisor"

if development && os.Getenv("SUPERVISOR_HOST") != "" {
supervisorHost = os.Getenv("SUPERVISOR_HOST")
}

u, err := url.Parse("http://" + supervisorHost + "/")
if err != nil {
// Handle error in parsing URL
w.Write([]byte(err.Error()))
Expand All @@ -75,7 +81,7 @@ func httpSupervisorProxy(w http.ResponseWriter, r *http.Request) {
return
}

// Extract subpath (e.g., resolution or network)
// Extract subPath (e.g., resolution or network)
subPath := parts[0]

// The remainder path (after the subpath) to be sanitized
Expand All @@ -100,6 +106,14 @@ func httpSupervisorProxy(w http.ResponseWriter, r *http.Request) {
// Add authorization header
r.Header.Add("Authorization", "Bearer "+os.Getenv("SUPERVISOR_TOKEN"))

if cleanPath == "/logs" {
// for logs download add text/plain headers
r.Header.Add("Accept", "text/plain")
} else if cleanPath == "/logs/follow" {
// Set FlushInterval to enable streaming
proxy.FlushInterval = -1
}

// Forward the request
proxy.ServeHTTP(w, r)
}
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ var development bool
func main() {
development = (os.Getenv("DEVELOPMENT") == "True")

if development {
if development && os.Getenv("FRONTEND_PATH") != "" {
wwwRoot = os.Getenv("FRONTEND_PATH") + "/landing-page/dist/"
} else if development {
wwwRoot = "./rootfs/usr/share/www/"
} else {
wwwRoot = "/usr/share/www/"
Expand All @@ -27,12 +29,16 @@ func main() {
http.HandleFunc("/api/", httpUnauthorized)
http.HandleFunc("/auth/token", httpBad)
http.HandleFunc("/observer/logs", httpLogs)
http.HandleFunc("/supervisor/supervisor/logs", httpSupervisorProxy)
http.HandleFunc("/supervisor/supervisor/logs/follow", httpSupervisorProxy)
http.HandleFunc("/supervisor/resolution/", httpSupervisorProxy)
http.HandleFunc("/supervisor/network/", httpSupervisorProxy)

// Serve static help files
staticFiles := http.FileServer(http.Dir(wwwRoot))
http.Handle("/landingpage/", http.StripPrefix("/landingpage", staticFiles))
http.Handle("/static/", staticFiles)
http.Handle("/frontend_es5/", staticFiles)
http.Handle("/frontend_latest/", staticFiles)

// Start mDNS broadcast
log.Print("Start mDNS broadcast")
Expand Down
2 changes: 2 additions & 0 deletions rootfs/usr/share/www/frontend_es5/13.VPS76DtYSIY.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rootfs/usr/share/www/frontend_es5/13.VPS76DtYSIY.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1f8c3b2

Please sign in to comment.