Server serves default content using go embed. Also add favicons/
This commit is contained in:
parent
058504a38f
commit
27eb2e5f12
14
internal/embeds/embeds.go
Normal file
14
internal/embeds/embeds.go
Normal 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
|
BIN
internal/embeds/static/android-chrome-192x192.png
Normal file
BIN
internal/embeds/static/android-chrome-192x192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
internal/embeds/static/android-chrome-512x512.png
Normal file
BIN
internal/embeds/static/android-chrome-512x512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
BIN
internal/embeds/static/apple-touch-icon.png
Normal file
BIN
internal/embeds/static/apple-touch-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
internal/embeds/static/favicon-16x16.png
Normal file
BIN
internal/embeds/static/favicon-16x16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 770 B |
BIN
internal/embeds/static/favicon-32x32.png
Normal file
BIN
internal/embeds/static/favicon-32x32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
internal/embeds/static/favicon.ico
Normal file
BIN
internal/embeds/static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
1
internal/embeds/static/site.webmanifest
Normal file
1
internal/embeds/static/site.webmanifest
Normal 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"}
|
35
internal/embeds/templates/index.html
Normal file
35
internal/embeds/templates/index.html
Normal 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>
|
@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/auth"
|
"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"
|
"git.coopcloud.tech/wiki-cafe/member-console/internal/middleware"
|
||||||
"github.com/rs/cors"
|
"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
|
BaseContext: func(_ net.Listener) context.Context { return ctx }, // Pass base context to all requests
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve the templates and static files
|
// Serve the templates and static files using embedded content
|
||||||
// Serve templates from the "templates" directory
|
// Serve templates from the embedded "templates" directory
|
||||||
httpRequestRouter.Handle("/", http.FileServer(http.Dir("./templates")))
|
httpRequestRouter.Handle("/", http.FileServer(http.FS(embeds.Templates)))
|
||||||
// Serve static files from the "static" directory
|
// Serve static files from the embedded "static" directory
|
||||||
httpRequestRouter.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
|
httpRequestRouter.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(embeds.Static))))
|
||||||
|
|
||||||
// Log server startup with structured logging
|
// Log server startup with structured logging
|
||||||
cfg.Logger.Info("starting server",
|
cfg.Logger.Info("starting server",
|
||||||
|
0
mc-config.yaml
Normal file
0
mc-config.yaml
Normal file
Loading…
x
Reference in New Issue
Block a user