mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
Some of the files were quite big:
- asns.csv ~ 3 MB
- index.js ~ 1.5 MB
- *.svg ~ 2 MB
Use a ZIP archive to put them all and embed it. This reduce the binary
size from 89 MB to 82 MB. 🤯
This also pulls some code modernization (use of http.ServeFileFS).
24 lines
675 B
Go
24 lines
675 B
Go
// SPDX-FileCopyrightText: 2022 Free Mobile
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package console
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func (c *Component) defaultHandlerFunc(w http.ResponseWriter, req *http.Request) {
|
|
assets := c.embedOrLiveFS("data/frontend")
|
|
http.ServeFileFS(w, req, assets, "index.html")
|
|
}
|
|
|
|
func (c *Component) staticAssetsHandlerFunc(w http.ResponseWriter, req *http.Request) {
|
|
assets := c.embedOrLiveFS("data/frontend/assets")
|
|
http.FileServer(http.FS(assets)).ServeHTTP(w, req)
|
|
}
|
|
|
|
func (c *Component) docAssetsHandlerFunc(w http.ResponseWriter, req *http.Request) {
|
|
docs := c.embedOrLiveFS("data/docs")
|
|
http.FileServer(http.FS(docs)).ServeHTTP(w, req)
|
|
}
|