minor reorg
This commit is contained in:
parent
1de19c6376
commit
b333ed97cf
12
main.go
12
main.go
@ -23,6 +23,7 @@ var (
|
||||
cert = flag.String("cert", "cert.pem", "certitifate")
|
||||
key = flag.String("key", "key.pem", "key")
|
||||
savedir = flag.String("d", "saved", "direcotry to save the pics.")
|
||||
tools = []Tool{}
|
||||
)
|
||||
|
||||
type Tool struct {
|
||||
@ -36,14 +37,16 @@ type Tool struct {
|
||||
BgColor string
|
||||
}
|
||||
|
||||
var tools = []Tool{}
|
||||
|
||||
func (t Tool) execute(in io.Reader, w http.ResponseWriter) {
|
||||
var cmd = exec.Command(t.Cmd, t.Args...) // Call to dot with SVG-output in safe-mode
|
||||
var (
|
||||
cmd = exec.Command(t.Cmd, t.Args...)
|
||||
err, buf = &bytes.Buffer{}, &bytes.Buffer{}
|
||||
)
|
||||
|
||||
cmd.Stdin = in
|
||||
err, buf := &bytes.Buffer{}, &bytes.Buffer{}
|
||||
cmd.Stderr = err
|
||||
cmd.Stdout = buf
|
||||
|
||||
if e := cmd.Run(); e == nil {
|
||||
io.Copy(w, buf)
|
||||
} else {
|
||||
@ -135,6 +138,7 @@ func (t Tool) index() func(http.ResponseWriter, *http.Request) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var tools = []Tool{}
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
"Name": "dot",
|
||||
"Cmd": "dot",
|
||||
"Args": ["-Tsvg", "-v"],
|
||||
"Args": ["-Tsvg"],
|
||||
"Suffix": ".dot",
|
||||
"Description": "Graphviz, dot",
|
||||
"BgColor": "CadetBlue",
|
||||
|
Loading…
Reference in New Issue
Block a user