-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
42 lines (35 loc) · 867 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package jaegerui
import (
"bytes"
"encoding/json"
"slices"
)
type Menu struct {
Label string `json:"label"`
Items []MenuItem `json:"items"`
}
type MenuItem struct {
Label string `json:"label"`
URL string `json:"url"`
}
type Config struct {
Dependencies struct {
MenuEnabled bool `json:"menuEnabled"`
} `json:"dependencies"`
Monitor struct {
MenuEnabled bool `json:"menuEnabled"`
} `json:"monitor"`
ArchiveEnabled bool `json:"archiveEnabled"`
Menu []Menu `json:"menu"`
}
func (cfg Config) Inject(name string, dt []byte) ([]byte, bool) {
if name != "index.html" {
return dt, false
}
cfgData, err := json.Marshal(cfg)
if err != nil {
return dt, false
}
dt = bytes.Replace(dt, []byte("const JAEGER_CONFIG = DEFAULT_CONFIG;"), slices.Concat([]byte(`const JAEGER_CONFIG = `), cfgData, []byte(`;`)), 1)
return dt, true
}