-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonhandler.go
51 lines (43 loc) · 1.07 KB
/
jsonhandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"os"
"sync"
)
func outputJSONHeader() string {
var header string
header = header + fmt.Sprintf("%s\n", "{")
header = header + fmt.Sprintf(" \"%s\": \"%s\",\n", "title", "httpreserve-linkstat")
header = header + fmt.Sprintf(" \"%s\": \"%s\",\n", "description", "httpreserve-linkstat-output")
header = header + fmt.Sprintf(" \"%s\": %s\n", "data", "[")
return header
}
func outputJSONFooter() string {
var footer string
footer = footer + fmt.Sprintf("%s\n%s\n", "]", "}")
return footer
}
var jsonCount int
// webappHanlder enables us to establish the web server and create
// the structures we need to present our data to the user...
func jsonHandler(js string) {
wg := new(sync.WaitGroup)
wg.Add(1)
go makejsonpool(js, wg)
wg.Wait()
return
}
var jsonpool []string
func makejsonpool(js string, wg *sync.WaitGroup) {
defer wg.Done()
jsonpool = append(jsonpool, js)
}
func outputjsonpool() {
for j := range jsonpool {
if j+1 < len(jsonpool) {
fmt.Fprint(os.Stdout, jsonpool[j]+",")
} else {
fmt.Fprint(os.Stdout, jsonpool[j])
}
}
}