/
main.go
49 lines (37 loc) · 807 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
package main
import (
"fmt"
_ "github.com/eraserxp/coedit/routers"
"github.com/astaxie/beego"
"net/http"
"net/url"
"github.com/eraserxp/coedit/controllers"
"log"
)
func startWebsocketProxy() error {
u, _ := url.Parse("ws://localhost:8001")
err := http.ListenAndServe(":8000", controllers.NewProxy(u))
if err != nil {
log.Fatalln(err)
return err
}
fmt.Println("start the websocket proxy")
return nil
}
func hook() error {
go startWebsocketProxy()
return nil
}
//func init() {
// startWebsocketProxy()
//}
func main() {
//run the websocket proxy
//startWebsocketProxy()
beego.AddAPPStartHook(hook)
//run the web server to serve the static files
beego.BConfig.WebConfig.StaticDir["/doc/static"] = "static"
fmt.Println("write into database")
//set session
beego.Run()
}