示例#1
0
文件: api.go 项目: pshevtsov/prgr
func token(next verigo.ContextHandler) verigo.ContextHandler {
	return verigo.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) {
		log.Infof(ctx, "Token Middleware")
		ctx = context.WithValue(ctx, "token", "ok")
		next.ServeHTTPContext(ctx, rw, req)
	})
}
示例#2
0
文件: api.go 项目: pshevtsov/prgr
func acl(next verigo.ContextHandler) verigo.ContextHandler {
	return verigo.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) {
		log.Infof(ctx, "ACL Middleware")
		ctx = context.WithValue(ctx, "acl", 1)
		next.ServeHTTPContext(ctx, rw, req)
	})
}
示例#3
0
文件: api.go 项目: pshevtsov/prgr
func validation(next verigo.ContextHandler) verigo.ContextHandler {
	return verigo.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) {
		log.Infof(ctx, "Validation Middleware")
		if req.FormValue("ok") == "false" {
			http.Error(rw, http.StatusText(400), http.StatusBadRequest)
			return
		}
		ctx = context.WithValue(ctx, "valid", true)
		next.ServeHTTPContext(ctx, rw, req)
	})
}
示例#4
0
文件: api.go 项目: pshevtsov/prgr
func gae(next verigo.ContextHandler) verigo.ContextHandler {
	return verigo.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) {
		ctx = appengine.NewContext(req)
		next.ServeHTTPContext(ctx, rw, req)
	})
}