func handleTXT(r Reporter) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "text/plain") renderer := render.LeafMap{Selector: report.SelectEndpoint, Mapper: mapFunc(req), Pseudo: nil} dot(w, renderer.Render(r.Report())) //report.Render(r.Report(), report.SelectEndpoint, mapFunc(req), report.NoPseudoNode)) } }
func handleSVG(r Reporter) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { cmd := exec.Command(engine(req), "-Tsvg") wc, err := cmd.StdinPipe() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } cmd.Stdout = w renderer := render.LeafMap{Selector: report.SelectEndpoint, Mapper: mapFunc(req), Pseudo: nil} dot(wc, renderer.Render(r.Report())) wc.Close() w.Header().Set("Content-Type", "image/svg+xml") if err := cmd.Run(); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } }