/
home.go
46 lines (37 loc) · 866 Bytes
/
home.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
package handlerssd
import (
"net/http"
"fmt"
"strconv"
"controllers/jwt"
)
func GetHome(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, dude")
}
func GetState(w http.ResponseWriter, r *http.Request) {
jwt.SetToken(w, r, strconv.Itoa(100500), "user")
longpollManager.SubscriptionHandler(w, r)
}
func PostState(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
fmt.Fprintf(w, "ParseForm() err: %v", err)
return
}
for key, value := range r.PostForm {
longpollManager.Publish(key, value[0])
}
/*
data := r.PostFormValue("stars")
if data != "" {
longpollManager.Publish("stars", data)
}
data = r.PostFormValue("overridestars")
if data != "" {
longpollManager.Publish("overridestars", data)
}
data = r.PostFormValue("net")
if data != "" {
longpollManager.Publish("net", data)
}
*/
}