コード例 #1
0
ファイル: techerhdl.go プロジェクト: lankecheng/pgserver
func ShowTeachers(w http.ResponseWriter, req *http.Request) {
	req.ParseForm()

	ok, err := serv.CheckToken(req.FormValue("token"))
	if err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	} else if !ok {
		http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
		return
	}

	teachers, err := serv.ShowTeachers()
	if err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.Write(pgpub.CreateQueryJson(teachers))
}
コード例 #2
0
ファイル: imhdl.go プロジェクト: lankecheng/pgserver
func WebsocketConnect(w http.ResponseWriter, req *http.Request) {
	req.ParseForm()

	oauthToken := req.FormValue("token")
	ok, err := serv.CheckToken(oauthToken)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	} else if !ok {
		http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
		return
	}

	uid, err := serv.GetUidFromToken(oauthToken)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	err = im.EstablishConnect(uid, w, req)
}