Merge pull request #474 from apachelogger/support-graph.dot

Allow requesting the unrendered dot graph from the graph endpoint
This commit is contained in:
Andrey Smirnov
2017-01-18 23:53:42 +03:00
committed by GitHub
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -22,3 +22,4 @@ List of contributors, in chronological order:
* Phil Frost (https://github.com/bitglue)
* Benoit Foucher (https://github.com/bentoi)
* Geoffrey Thomas (https://github.com/geofft)
* Harald Sitter (https://github.com/apachelogger)
+7
View File
@@ -39,6 +39,13 @@ func apiGraph(c *gin.Context) {
buf := bytes.NewBufferString(graph.String())
if ext == "dot" || ext == "gv" {
// If the raw dot data is requested, return it as string.
// This allows client-side rendering rather than server-side.
c.String(200, buf.String())
return
}
command := exec.Command("dot", "-T"+ext)
command.Stderr = os.Stderr
+4
View File
@@ -15,3 +15,7 @@ class GraphAPITest(APITest):
resp = self.get("/api/graph.svg")
self.check_equal(resp.headers["Content-Type"], "image/svg+xml")
self.check_equal(resp.content[:4], '<?xm')
resp = self.get("/api/graph.dot")
self.check_equal(resp.headers["Content-Type"], "text/plain; charset=utf-8")
self.check_equal(resp.content[:13], 'digraph aptly')