embed static files
All checks were successful
cicd / cicd (push) Successful in 44s

This commit is contained in:
bel
2023-10-28 10:38:28 -06:00
parent cb6e23a498
commit 432b2df131
3 changed files with 10 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package http
import (
"embed"
"encoding/json"
"flag"
"fmt"
@@ -16,12 +17,17 @@ import (
"strings"
"time"
_ "embed"
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/opts"
"gogs.inhome.blapointe.com/ana-ledger/src/ana"
"gogs.inhome.blapointe.com/ana-ledger/src/ledger"
)
//go:embed public/*
var staticFileDir embed.FS
func Main() {
foo := flag.String("foo", "bal", "bal or reg")
likeName := flag.String("like-name", ".", "regexp to match")
@@ -55,7 +61,7 @@ func Main() {
if *httpOutput != "" {
foo := func(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.URL.Path, "/api") {
http.FileServer(http.Dir("./http/public")).ServeHTTP(w, r)
http.FileServer(http.FS(staticFileDir)).ServeHTTP(w, r)
return
}