func checkUserName(res http.ResponseWriter, req *http.Request, _ httprouter.Params) { ctx := appengine.NewContext(req) bs, err := ioutil.ReadAll(req.Body) sbs := string(bs) log.Infof(ctx, "REQUEST BODY: %v", sbs) var user User key := datastore.NewKey(ctx, "Users", sbs, 0, nil) err = datastore.Get(ctx, key, &user) // if there is an err, there is NO user log.Infof(ctx, "ERR: %v", err) if err != nil { // there is an err, there is a NO user fmt.Fprint(res, "false") return } else { fmt.Fprint(res, "true") } }
func getSession(req *http.Request) *memcache.Item { cookie, err := req.Cookie("session") if err != nil { return &memcache.Item{} } ctx := appengine.NewContext(req) item, err := memcache.Get(ctx, cookie.Value) if err != nil { return &memcache.Item{} } log.Infof(ctx, "%s", string(item.Value)) return item }