Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generated frontend from frontend repo #129

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
}
}
}
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