-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.go
66 lines (59 loc) · 1.25 KB
/
http.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package app
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/buger/jsonparser"
)
func (a *AppType) PingResponse(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, a.Name)
}
func (a *AppType) FolderResponse(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, a.Folder)
}
func ExtractSessionInfo(req *http.Request) map[string]string {
m := map[string]string{}
b, err := ioutil.ReadAll(req.Body)
if err != nil {
log.Println(err)
return m
}
jsonparser.EachKey(b, func(i int, value []byte, vt jsonparser.ValueType, err error) {
if err != nil {
return
}
switch i {
case 0:
m["session_id"] = string(value)
case 1:
m["began"] = string(value)
case 2:
m["finished"] = string(value)
case 3:
m["task_name"] = string(value)
case 4:
m["brcd"] = string(value)
case 5:
m["printer"] = string(value)
case 6:
m["ref"] = string(value)
case 7:
m["content"] = string(value)
case 8:
m["queue_name"] = string(value)
case 9:
m["timeout"] = string(value)
}
}, []string{"session_id"},
[]string{"began"},
[]string{"finished"},
[]string{"task_name"},
[]string{"brcd"},
[]string{"printer"},
[]string{"ref"},
[]string{"content"},
[]string{"queue_name"},
[]string{"timeout"})
return m
}