This commit is contained in:
26
main.go
26
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -32,6 +33,22 @@ var replacements = make(Replacements)
|
|||||||
//go:embed www/*
|
//go:embed www/*
|
||||||
var staticContent embed.FS
|
var staticContent embed.FS
|
||||||
|
|
||||||
|
func getAllFilenames(efs *embed.FS) (files []string, err error) {
|
||||||
|
if err := fs.WalkDir(efs, ".", func(path string, d fs.DirEntry, err error) error {
|
||||||
|
if d.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
files = append(files, path)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return files, nil
|
||||||
|
}
|
||||||
|
|
||||||
// staticFileServer serves files from the provided fs.FS
|
// staticFileServer serves files from the provided fs.FS
|
||||||
func staticFileServer(content embed.FS) gin.HandlerFunc {
|
func staticFileServer(content embed.FS) gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
@@ -102,6 +119,15 @@ func main() {
|
|||||||
log.SetOutput(logfileWriter)
|
log.SetOutput(logfileWriter)
|
||||||
log.Printf("SMT starting execution. Built on %s from sha1 %s\n", buildTime, sha1ver)
|
log.Printf("SMT starting execution. Built on %s from sha1 %s\n", buildTime, sha1ver)
|
||||||
|
|
||||||
|
files, err := getAllFilenames(&staticContent)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Unable to access embedded fs : '%s'\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range files {
|
||||||
|
log.Printf("Embedded file : '%s'\n", files[i])
|
||||||
|
}
|
||||||
|
|
||||||
// Initiate connection to sqlite and make sure our schema is up to date
|
// Initiate connection to sqlite and make sure our schema is up to date
|
||||||
models.ConnectDatabase()
|
models.ConnectDatabase()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user