本文整理汇总了Golang中github.com/skypies/complaints/complaintdb.ComplaintDB.PutProfile方法的典型用法代码示例。如果您正苦于以下问题:Golang ComplaintDB.PutProfile方法的具体用法?Golang ComplaintDB.PutProfile怎么用?Golang ComplaintDB.PutProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/complaints/complaintdb.ComplaintDB
的用法示例。
在下文中一共展示了ComplaintDB.PutProfile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: profileUpdateHandler
func profileUpdateHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
session := sessions.Get(r)
if session.Values["email"] == nil {
c.Errorf("profileUpdate:, session was empty; no cookie ?")
http.Error(w, "session was empty; no cookie ? is this browser in privacy mode ?",
http.StatusInternalServerError)
return
}
email := session.Values["email"].(string)
r.ParseForm()
lat, err := strconv.ParseFloat(r.FormValue("Lat"), 64)
if err != nil {
c.Errorf("profileUpdate:, parse lat '%s': %v", r.FormValue("Lat"), err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
long, err2 := strconv.ParseFloat(r.FormValue("Long"), 64)
if err2 != nil {
c.Errorf("profileUpdate:, parse long '%s': %v", r.FormValue("Long"), err)
http.Error(w, err2.Error(), http.StatusInternalServerError)
return
}
// Maybe make a call to fetch the elevation ??
// https://developers.google.com/maps/documentation/elevation/intro
cp := types.ComplainerProfile{
EmailAddress: email,
CallerCode: r.FormValue("CallerCode"),
FullName: strings.TrimSpace(r.FormValue("FullName")),
Address: strings.TrimSpace(r.FormValue("AutoCompletingMagic")),
StructuredAddress: types.PostalAddress{
Number: r.FormValue("AddrNumber"),
Street: r.FormValue("AddrStreet"),
City: r.FormValue("AddrCity"),
State: r.FormValue("AddrState"),
Zip: r.FormValue("AddrZip"),
Country: r.FormValue("AddrCountry"),
},
CcSfo: true, //FormValueCheckbox(r, "CcSfo"),
Lat: lat,
Long: long,
}
cdb := complaintdb.ComplaintDB{C: c}
err = cdb.PutProfile(cp)
if err != nil {
c.Errorf("profileUpdate: cdb.Put: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/", http.StatusFound)
}