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")
|
cert = flag.String("cert", "cert.pem", "certitifate")
|
||||||
key = flag.String("key", "key.pem", "key")
|
key = flag.String("key", "key.pem", "key")
|
||||||
savedir = flag.String("d", "saved", "direcotry to save the pics.")
|
savedir = flag.String("d", "saved", "direcotry to save the pics.")
|
||||||
|
tools = []Tool{}
|
||||||
)
|
)
|
||||||
|
|
||||||
type Tool struct {
|
type Tool struct {
|
||||||
@ -36,14 +37,16 @@ type Tool struct {
|
|||||||
BgColor string
|
BgColor string
|
||||||
}
|
}
|
||||||
|
|
||||||
var tools = []Tool{}
|
|
||||||
|
|
||||||
func (t Tool) execute(in io.Reader, w http.ResponseWriter) {
|
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
|
cmd.Stdin = in
|
||||||
err, buf := &bytes.Buffer{}, &bytes.Buffer{}
|
|
||||||
cmd.Stderr = err
|
cmd.Stderr = err
|
||||||
cmd.Stdout = buf
|
cmd.Stdout = buf
|
||||||
|
|
||||||
if e := cmd.Run(); e == nil {
|
if e := cmd.Run(); e == nil {
|
||||||
io.Copy(w, buf)
|
io.Copy(w, buf)
|
||||||
} else {
|
} else {
|
||||||
@ -135,6 +138,7 @@ func (t Tool) index() func(http.ResponseWriter, *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var tools = []Tool{}
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"Name": "dot",
|
"Name": "dot",
|
||||||
"Cmd": "dot",
|
"Cmd": "dot",
|
||||||
"Args": ["-Tsvg", "-v"],
|
"Args": ["-Tsvg"],
|
||||||
"Suffix": ".dot",
|
"Suffix": ".dot",
|
||||||
"Description": "Graphviz, dot",
|
"Description": "Graphviz, dot",
|
||||||
"BgColor": "CadetBlue",
|
"BgColor": "CadetBlue",
|
||||||
|
Loading…
Reference in New Issue
Block a user