(w http.ResponseWriter, req *http.Request)
| 93 | } |
| 94 | |
| 95 | func (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 | } |
nothing calls this directly
no test coverage detected