예제 #1
0
파일: handle.go 프로젝트: neviim/scope
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))
	}
}
예제 #2
0
파일: handle.go 프로젝트: neviim/scope
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
		}
	}
}