aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2017-11-22 19:28:32 -0800
committerÖzgür Kesim <oec@codeblau.de>2017-11-22 19:28:32 -0800
commitb333ed97cf7fc38a3a318544f53e1798e3c5d7e4 (patch)
tree2528a9964cb7bb079e3580c67e0281163eef59d9 /main.go
parent1de19c63760862ffd1644229a775ef51d9d27dba (diff)
minor reorg
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.go b/main.go
index 9c3112f..1b53ecd 100644
--- a/main.go
+++ b/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()