示例#1
0
文件: main.go 项目: jamal/flannel
// Hello is an example endpoint
func Hello(w http.ResponseWriter, r *http.Request) {
	ctx := &myContext{}
	flannel.Context(r, &ctx)
	flannel.LogInfo(r, "Hello was called by %s", ctx.Name)

	flannel.Write(w, http.StatusOK, fmt.Sprintf("Hello, %s. I've been called %d times.", ctx.Name, ctx.Counter))
}
示例#2
0
文件: form.go 项目: jamal/flannel
func Login(w http.ResponseWriter, r *http.Request) {
	login := &LoginForm{}
	flannel.DecodeForm(r, login)

	flannel.Write(w, http.StatusForbidden, fmt.Sprintf("User %s does not exist", login.Username))
}