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

Method ProgzHandler

internal/runtime/httpstatus.go:95–117  ·  view source on GitHub ↗
(w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

93}
94
95func (r *Runtime) ProgzHandler(w http.ResponseWriter, req *http.Request) {
96 prog := req.URL.Query().Get("prog")
97 if prog != "" {
98 r.handleMu.RLock()
99 handle, ok := r.handles[prog]
100 r.handleMu.RUnlock()
101 if !ok {
102 http.Error(w, "No program found", http.StatusNotFound)
103 return
104 }
105 fmt.Fprint(w, handle.vm.DumpByteCode())
106 fmt.Fprintf(w, "\nLast runtime error:\n%s", handle.vm.RuntimeErrorString())
107 return
108 }
109 r.handleMu.RLock()
110 defer r.handleMu.RUnlock()
111 w.Header().Add("Content-type", "text/html")
112 fmt.Fprintf(w, "<ul>")
113 for prog := range r.handles {
114 fmt.Fprintf(w, "<li><a href=\"?prog=%s\">%s</a></li>", prog, prog)
115 }
116 fmt.Fprintf(w, "</ul>")
117}

Callers

nothing calls this directly

Calls 5

DumpByteCodeMethod · 0.80
RuntimeErrorStringMethod · 0.80
ErrorMethod · 0.65
GetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected