| 59 | var once sync.Once |
| 60 | |
| 61 | func 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 | |
| 87 | type Server struct { |
| 88 | HijackPath string |