@@ -19,9 +19,10 @@ import (
1919
2020// EmbedFolder returns an http.HandlerFunc that serves an embedded filesystem
2121// with SPA fallback support (serves index.html for non-existent routes)
22- // For index.html, it replaces __ACKIFY_BASE_URL__ placeholder with the actual base URL
22+ // For index.html, it replaces __ACKIFY_BASE_URL__ placeholder with the actual base URL,
23+ // __ACKIFY_VERSION__ with the application version,
2324// and __META_TAGS__ with dynamic meta tags based on query parameters
24- func EmbedFolder (fsEmbed embed.FS , targetPath string , baseURL string , signatureRepo * database.SignatureRepository ) http.HandlerFunc {
25+ func EmbedFolder (fsEmbed embed.FS , targetPath string , baseURL string , version string , signatureRepo * database.SignatureRepository ) http.HandlerFunc {
2526 return func (w http.ResponseWriter , r * http.Request ) {
2627 fsys , err := fs .Sub (fsEmbed , targetPath )
2728 if err != nil {
@@ -60,7 +61,7 @@ func EmbedFolder(fsEmbed embed.FS, targetPath string, baseURL string, signatureR
6061 defer file .Close ()
6162
6263 if shouldServeIndex || strings .HasSuffix (cleanPath , "index.html" ) {
63- serveIndexTemplate (w , r , file , baseURL , signatureRepo )
64+ serveIndexTemplate (w , r , file , baseURL , version , signatureRepo )
6465 return
6566 }
6667
@@ -69,7 +70,7 @@ func EmbedFolder(fsEmbed embed.FS, targetPath string, baseURL string, signatureR
6970 }
7071}
7172
72- func serveIndexTemplate (w http.ResponseWriter , r * http.Request , file fs.File , baseURL string , signatureRepo * database.SignatureRepository ) {
73+ func serveIndexTemplate (w http.ResponseWriter , r * http.Request , file fs.File , baseURL string , version string , signatureRepo * database.SignatureRepository ) {
7374 content , err := io .ReadAll (file )
7475 if err != nil {
7576 logger .Logger .Error ("Failed to read index.html" , "error" , err .Error ())
@@ -78,6 +79,7 @@ func serveIndexTemplate(w http.ResponseWriter, r *http.Request, file fs.File, ba
7879 }
7980
8081 processedContent := strings .ReplaceAll (string (content ), "__ACKIFY_BASE_URL__" , baseURL )
82+ processedContent = strings .ReplaceAll (processedContent , "__ACKIFY_VERSION__" , version )
8183
8284 metaTags := generateMetaTags (r , baseURL , signatureRepo )
8385 processedContent = strings .ReplaceAll (processedContent , "__META_TAGS__" , metaTags )
0 commit comments