MCPcopy Index your code
hub / github.com/subtrace/subtrace / bundleOnce

Function bundleOnce

devtools/devtools.go:61–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59var once sync.Once
60
61func bundleOnce() {
62 once.Do(func() {
63 f, err := bundle.Open("bundle/devtools.js.gz")
64 if err != nil {
65 html = fallback("This build of subtrace was compiled without Chrome DevTools support.")
66 return
67 }
68 defer f.Close()
69
70 r, err := gzip.NewReader(f)
71 if err != nil {
72 html = fallback(fmt.Sprintf("Subtrace failed to extract the gzip devtools bundle.<br><br>Error: %q", fmt.Errorf("create: %w", err)))
73 return
74 }
75
76 bundle, err := io.ReadAll(r)
77 if err != nil {
78 html = fallback(fmt.Sprintf("Subtrace failed to extract the gzip devtools bundle.<br><br>Error: %q", fmt.Errorf("read: %w", err)))
79 return
80 }
81
82 html = bytes.ReplaceAll(html, []byte("__DEVTOOLS_BUNDLE__"), bundle)
83 html = bytes.ReplaceAll(html, []byte("__SUBTRACE_INIT__"), initJS)
84 })
85}
86
87type Server struct {
88 HijackPath string

Callers 1

htmlMethod · 0.85

Calls 2

fallbackFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected