Server serves default content using go embed. Also add favicons/

This commit is contained in:
Christian Galo 2025-05-13 00:52:52 -05:00
parent 058504a38f
commit 27eb2e5f12
14 changed files with 56 additions and 5 deletions

14
internal/embeds/embeds.go Normal file
View File

@ -0,0 +1,14 @@
package embeds
import (
"embed"
)
//go:embed static
var Static embed.FS
//go:embed templates
var Templates embed.FS
//go:embed mc-config.yaml
var Config embed.FS

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Your Page Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Brief description">
<meta property="og:title" content="Your Page Title">
<meta property="og:description" content="Brief description">
<meta property="og:image" content="/some-image.png">
<meta property="og:url" content="/this-page.html">
<meta property="og:site_name" content="Your Site Name">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image:alt" content="image description">
<link href="/static/bootstrap.css" rel="stylesheet">
<script defer src="/static/bootstrap.bundle.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<link rel="manifest" href="/static/site.webmanifest">
</head>
<body>
<h1>Your content here!</h1>
</body>
</html>

View File

@ -8,6 +8,7 @@ import (
"time"
"git.coopcloud.tech/wiki-cafe/member-console/internal/auth"
"git.coopcloud.tech/wiki-cafe/member-console/internal/embeds"
"git.coopcloud.tech/wiki-cafe/member-console/internal/middleware"
"github.com/rs/cors"
)
@ -86,11 +87,11 @@ func Start(ctx context.Context, cfg Config) error {
BaseContext: func(_ net.Listener) context.Context { return ctx }, // Pass base context to all requests
}
// Serve the templates and static files
// Serve templates from the "templates" directory
httpRequestRouter.Handle("/", http.FileServer(http.Dir("./templates")))
// Serve static files from the "static" directory
httpRequestRouter.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
// Serve the templates and static files using embedded content
// Serve templates from the embedded "templates" directory
httpRequestRouter.Handle("/", http.FileServer(http.FS(embeds.Templates)))
// Serve static files from the embedded "static" directory
httpRequestRouter.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(embeds.Static))))
// Log server startup with structured logging
cfg.Logger.Info("starting server",

0
mc-config.yaml Normal file
View File