我的以下代码package inqzincrmimport ( "github.com/gorilla/pat" "github.com/gorilla/sessions" "net/http")var store = sessions.NewCookieStore([]byte("X12h8v6BZC4QJl53KfNLshtr85gkC5OZ"), []byte("X12h8vasdf6BZC4QJl53KfNLshtr85gk"))func init() { r := pat.New() r.Get("/", Home) http.Handle("/", r)}在处理程序中,package inqzincrmimport ( "appengine" "html/template" "net/http")var aTmplt = template.Must(template.ParseFiles( "inqzincrm/templates/base.html", "inqzincrm/templates/index.html",))func Home(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) session, err := store.Get(r, "x") c.Infof("HOST: %s", r.Host) if session.IsNew { session.Options.Domain = r.Host session.Options.Path = "/" session.Options.MaxAge = 0 session.Options.HttpOnly = false session.Options.Secure = false } if err != nil { c.Infof("Error getting session: %v", err) } c.Infof("Requested URL: %v", session.Values["foo"]) session.Values["foo"] = "asdf" if err := aTmplt.ExecuteTemplate(w, "index.html", nil); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } session.Save(r, w)}不要在浏览器端设置任何 cookie。结果和错误如何为零表示函数没有问题。我应该如何进一步调试?我正在使用 Ubuntu 64 位、Google App Engine、Go with Gorilla 工具包。
- 2 回答
- 0 关注
- 210 浏览
添加回答
举报
0/150
提交
取消