MCPcopy
hub / github.com/gotify/server / Register

Function Register

ui/serve.go:24–44  ·  view source on GitHub ↗

Register registers the ui on the root path.

(r *gin.Engine, version model.VersionInfo, register bool)

Source from the content-addressed store, hash-verified

22
23// Register registers the ui on the root path.
24func Register(r *gin.Engine, version model.VersionInfo, register bool) {
25 uiConfigBytes, err := json.Marshal(uiConfig{Version: version, Register: register})
26 if err != nil {
27 panic(err)
28 }
29
30 replaceConfig := func(content string) string {
31 return strings.Replace(content, "%CONFIG%", string(uiConfigBytes), 1)
32 }
33
34 ui := r.Group("/", gzip.Gzip(gzip.DefaultCompression))
35 ui.GET("/", serveFile("index.html", "text/html", replaceConfig))
36 ui.GET("/index.html", serveFile("index.html", "text/html", replaceConfig))
37 ui.GET("/manifest.json", serveFile("manifest.json", "application/json", noop))
38
39 subBox, err := fs.Sub(box, "build")
40 if err != nil {
41 panic(err)
42 }
43 ui.GET("/static/*any", gin.WrapH(http.FileServer(http.FS(subBox))))
44}
45
46func noop(s string) string {
47 return s

Callers 1

CreateFunction · 0.92

Calls 1

serveFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…