-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (43 loc) · 970 Bytes
/
main.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 (
"log"
"net/http"
"github.com/gorilla/websocket"
"github.com/gorilla/sessions"
)
var upgrader =websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true // Accepting all requests
},
ReadBufferSize:1024,
WriteBufferSize:1024,
}
var counter map[string] string
var count=0
var store=sessions.NewCookieStore([]byte("test"))
type Profile struct{
Uid string `json:"uid"`
Messages string `json:"messages"`
}
var api Profile
func cut(s string) string{
pos:=0
for i:=len(s)-1; i>-1;i--{
if s[i]==':' {
pos=i
break
}
}
s=s[pos+1:]
return s
}
func main(){
counter=make(map[string]string)
fs := http.FileServer(http.Dir("html/"))
http.Handle("/static/", http.StripPrefix("/static/", fs))
http.HandleFunc("/",mainpage)
http.HandleFunc("/echo",sock)
http.HandleFunc("/encode",jsonthrow)
log.Println("starting server 8080")
log.Fatal(http.ListenAndServe(":8080",nil))
}