mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
Merge pull request #474 from apachelogger/support-graph.dot
Allow requesting the unrendered dot graph from the graph endpoint
This commit is contained in:
@@ -22,3 +22,4 @@ List of contributors, in chronological order:
|
|||||||
* Phil Frost (https://github.com/bitglue)
|
* Phil Frost (https://github.com/bitglue)
|
||||||
* Benoit Foucher (https://github.com/bentoi)
|
* Benoit Foucher (https://github.com/bentoi)
|
||||||
* Geoffrey Thomas (https://github.com/geofft)
|
* Geoffrey Thomas (https://github.com/geofft)
|
||||||
|
* Harald Sitter (https://github.com/apachelogger)
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ func apiGraph(c *gin.Context) {
|
|||||||
|
|
||||||
buf := bytes.NewBufferString(graph.String())
|
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 := exec.Command("dot", "-T"+ext)
|
||||||
command.Stderr = os.Stderr
|
command.Stderr = os.Stderr
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,7 @@ class GraphAPITest(APITest):
|
|||||||
resp = self.get("/api/graph.svg")
|
resp = self.get("/api/graph.svg")
|
||||||
self.check_equal(resp.headers["Content-Type"], "image/svg+xml")
|
self.check_equal(resp.headers["Content-Type"], "image/svg+xml")
|
||||||
self.check_equal(resp.content[:4], '<?xm')
|
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')
|
||||||
|
|||||||
Reference in New Issue
Block a user