Update architecture
This commit is contained in:
parent
f4f3062352
commit
a1bb6e4783
@ -6,7 +6,7 @@ WORKDIR /app
|
|||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY main.go index.html favicon.ico ./
|
COPY main.go index.html favicon.png ./
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o nats-ui main.go
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o nats-ui main.go
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
|
|||||||
8
main.go
8
main.go
@ -18,7 +18,7 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed index.html favicon.ico
|
//go:embed index.html favicon.png
|
||||||
var staticFS embed.FS
|
var staticFS embed.FS
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{
|
var upgrader = websocket.Upgrader{
|
||||||
@ -315,7 +315,7 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
indexHTML, _ := staticFS.ReadFile("index.html")
|
indexHTML, _ := staticFS.ReadFile("index.html")
|
||||||
faviconICO, _ := staticFS.ReadFile("favicon.ico")
|
faviconPNG, _ := staticFS.ReadFile("favicon.png")
|
||||||
|
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.URL.Path {
|
switch r.URL.Path {
|
||||||
@ -324,9 +324,9 @@ func main() {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, _ = w.Write(indexHTML)
|
_, _ = w.Write(indexHTML)
|
||||||
case "/favicon.ico":
|
case "/favicon.ico":
|
||||||
w.Header().Set("Content-Type", "image/x-icon")
|
w.Header().Set("Content-Type", "image/png")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, _ = w.Write(faviconICO)
|
_, _ = w.Write(faviconPNG)
|
||||||
default:
|
default:
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user