app.go (1329:d4d7d2ca74b1) app.go (1490:cecf6b11a1e3)
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "net/http"
7 "unit.nginx.org/go"
8 "os"

--- 7 unchanged lines hidden (view full) ---

16 IPC uint64
17 CGROUP uint64
18 UTS uint64
19 MNT uint64
20 NET uint64
21 }
22
23 Output struct {
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "net/http"
7 "unit.nginx.org/go"
8 "os"

--- 7 unchanged lines hidden (view full) ---

16 IPC uint64
17 CGROUP uint64
18 UTS uint64
19 MNT uint64
20 NET uint64
21 }
22
23 Output struct {
24 PID int
25 UID int
26 GID int
27 NS NS
24 PID int
25 UID int
26 GID int
27 NS NS
28 FileExists bool
28 }
29)
30
31func abortonerr(err error) {
32 if err != nil {
33 panic(err)
34 }
35}

--- 23 unchanged lines hidden (view full) ---

59 USER: getns("user"),
60 MNT: getns("mnt"),
61 IPC: getns("ipc"),
62 UTS: getns("uts"),
63 NET: getns("net"),
64 CGROUP: getns("cgroup"),
65 },
66 }
29 }
30)
31
32func abortonerr(err error) {
33 if err != nil {
34 panic(err)
35 }
36}

--- 23 unchanged lines hidden (view full) ---

60 USER: getns("user"),
61 MNT: getns("mnt"),
62 IPC: getns("ipc"),
63 UTS: getns("uts"),
64 NET: getns("net"),
65 CGROUP: getns("cgroup"),
66 },
67 }
68
69 err := r.ParseForm()
70 if err != nil {
71 w.WriteHeader(http.StatusInternalServerError)
72 return
73 }
74
75 if fname := r.Form.Get("file"); fname != "" {
76 _, err = os.Stat(fname);
77 out.FileExists = err == nil
78 }
79
67 data, err := json.Marshal(out)
68 if err != nil {
69 w.WriteHeader(http.StatusInternalServerError)
70 return
71 }
72
73 w.Header().Add("Content-Type", "application/json")
74
75 w.Write(data)
76}
77
78func main() {
79 http.HandleFunc("/", handler)
80 unit.ListenAndServe(":7080", nil)
81}
80 data, err := json.Marshal(out)
81 if err != nil {
82 w.WriteHeader(http.StatusInternalServerError)
83 return
84 }
85
86 w.Header().Add("Content-Type", "application/json")
87
88 w.Write(data)
89}
90
91func main() {
92 http.HandleFunc("/", handler)
93 unit.ListenAndServe(":7080", nil)
94}