Ejemplo n.º 1
0
func Ping(res http.ResponseWriter, req *http.Request, sres *http.Response) {
	sdata, err := ioutil.ReadAll(sres.Body)
	check(err)
	var obj map[string]*json.RawMessage
	err = json.Unmarshal(sdata, &obj)
	check(err)
	err = json.Unmarshal(*obj["id"], &userid)
	check(err)
	port, err := strconv.Atoi(info.Port())
	check(err)
	ping := map[string]int{
		"userid": userid,
		"port":   port,
	}
	jsstr, err := json.Marshal(ping)
	check(err)
	_, err = http.Post("http://diamondnotcrush.herokuapp.com/connection/addConnection", "application/json", bytes.NewReader(jsstr))
	check(err)
	http.Redirect(res, req, "/", 302)
}
Ejemplo n.º 2
0
func MainPage(res http.ResponseWriter, req *http.Request) {
	if !info.CheckAddr(req.RemoteAddr) {
		return
	}
	portal.MainPage(res, req, info.Dir(), info.Port(), verify, userid)
}
Ejemplo n.º 3
0
func main() {
	port := info.Port()
	log.Println("Listening on port " + port)
	open.Start("http://127.0.0.1:" + port)
	http.ListenAndServe(":"+port, router.Routes())
}