1 Star 1 Fork 0

湖底观景/GolangTraining

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 784 Bytes
一键复制 编辑 原始数据 按行查看 历史
GoesToEleven 提交于 2016-04-21 08:45 +08:00 . changes dir structure
package example
import (
"fmt"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"net/http"
)
type Entity struct {
Value string
}
func init() {
http.HandleFunc("/", home)
http.Handle("/favicon.ico", http.NotFoundHandler())
}
func home(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
k := datastore.NewKey(c, "Entity", "todd.mcleod@fresnocitycollege.edu", 0, nil)
e := new(Entity)
if err := datastore.Get(c, k, e); err != nil {
http.Error(w, err.Error(), 500)
return
}
old := e.Value
e.Value = r.URL.Path
if _, err := datastore.Put(c, k, e); err != nil {
http.Error(w, err.Error(), 500)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
fmt.Fprintf(w, "old=%q\nnew=%q\n", old, e.Value)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjianGood/GolangTraining.git
git@gitee.com:zhangjianGood/GolangTraining.git
zhangjianGood
GolangTraining
GolangTraining
afa19f5c43f3

搜索帮助