MCPcopy
hub / github.com/google/mtail / WriteStatusHTML

Method WriteStatusHTML

internal/runtime/httpstatus.go:48–93  ·  view source on GitHub ↗

WriteStatusHTML writes the current state of the loader as HTML to the given writer w.

(w io.Writer)

Source from the content-addressed store, hash-verified

46
47// WriteStatusHTML writes the current state of the loader as HTML to the given writer w.
48func (r *Runtime) WriteStatusHTML(w io.Writer) error {
49 t, err := template.New("loader").Parse(loaderTemplate)
50 if err != nil {
51 return err
52 }
53 r.programErrorMu.RLock()
54 defer r.programErrorMu.RUnlock()
55 data := struct {
56 ProgLoaded map[string]bool
57 Errors map[string]error
58 Loaderrors map[string]string
59 Loadsuccess map[string]string
60 Unloads map[string]string
61 RuntimeErrors map[string]string
62 RuntimeErrorString map[string]string
63 }{
64 make(map[string]bool),
65 r.programErrors,
66 make(map[string]string),
67 make(map[string]string),
68 make(map[string]string),
69 make(map[string]string),
70 make(map[string]string),
71 }
72 for name := range r.programErrors {
73 if ProgLoadErrors.Get(name) != nil {
74 data.Loaderrors[name] = ProgLoadErrors.Get(name).String()
75 }
76 if ProgLoads.Get(name) != nil {
77 data.Loadsuccess[name] = ProgLoads.Get(name).String()
78 }
79 if ProgUnloads.Get(name) != nil {
80 data.Unloads[name] = ProgUnloads.Get(name).String()
81 }
82 if vm.ProgRuntimeErrors.Get(name) != nil {
83 data.RuntimeErrors[name] = vm.ProgRuntimeErrors.Get(name).String()
84 }
85 r.handleMu.RLock()
86 if h, ok := r.handles[name]; ok {
87 data.ProgLoaded[name] = true
88 data.RuntimeErrorString[name] = h.vm.RuntimeErrorString()
89 }
90 r.handleMu.RUnlock()
91 }
92 return t.Execute(w, data)
93}
94
95func (r *Runtime) ProgzHandler(w http.ResponseWriter, req *http.Request) {
96 prog := req.URL.Query().Get("prog")

Callers

nothing calls this directly

Calls 4

RuntimeErrorStringMethod · 0.80
ParseMethod · 0.65
StringMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected