當前位置: 首頁>>代碼示例>>Golang>>正文


Golang appstats.NewHandler函數代碼示例

本文整理匯總了Golang中github.com/mjibson/appstats.NewHandler函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewHandler函數的具體用法?Golang NewHandler怎麽用?Golang NewHandler使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewHandler函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: init

func init() {
	m := pat.New()
	m.Post("/signups", appstats.NewHandler(createSignUpAsync))
	m.Post("/signups/task", appstats.NewHandler(createSignUp))
	m.Get("/sendemail", appstats.NewHandler(sendEmail))
	m.Get("/", appstats.NewHandler(newSignUp))
	http.Handle("/", m)
}
開發者ID:matservant,項目名稱:all-ads,代碼行數:8,代碼來源:http.go

示例2: appstatsWrapper

func appstatsWrapper(h Handler) http.Handler {
	f := func(c appengine.Context, w http.ResponseWriter, req *http.Request) {
		// Emit some compatibility & anti-cache headers for IE (you can overwrite
		// them from the handlers)
		w.Header().Set("X-UA-Compatible", "chrome=1")
		w.Header().Set("Cache-Control", "max-age=0,no-cache,no-store,"+
			"post-check=0,pre-check=0")
		w.Header().Set("Expires", "Mon, 26 Jul 1997 05:00:00 GMT")

		// Build the request & session objects
		rw := newResponseWriter(w)
		r := &Request{Req: req, W: rw, C: c, N: goon.FromContext(c)}

		session, token, err := getSession(req, rw)
		if err != nil {
			r.processError(fmt.Errorf("build session failed: %s", err))
			return
		}
		r.Session = session

		// Check XSRF token
		if req.Method != "GET" {
			if ok, err := checkXsrfToken(req, token); err != nil {
				r.processError(fmt.Errorf("check xsrf token failed: %s", err))
				return
			} else if !ok {
				c.Errorf("xsrf token header check failed")
				r.processError(Forbidden())
				return
			}
		}

		// Fatal errors recovery
		defer func() {
			if rec := recover(); rec != nil {
				err := fmt.Errorf("panic recovered error: %s", rec)
				r.processError(err)
			}
		}()

		// Handle the request
		if err := h(r); err != nil {
			r.processError(err)
		}

		// Save the session & copy the buffered output
		if err := sessions.Save(req, w); err != nil {
			r.processError(err)
		}
		if err := rw.output(); err != nil {
			r.processError(err)
		}
	}
	return appstats.NewHandler(f)
}
開發者ID:ernestoalejo,項目名稱:gaelib,代碼行數:55,代碼來源:router.go

示例3: init

func init() {
	http.Handle("/print", appstats.NewHandler(blobList))
	http.Handle("/blob2", appstats.NewHandler(blobList))
	http.Handle("/blob2/upload", appstats.NewHandler(submitUpload))
	http.Handle("/blob2/processing-new-upload", appstats.NewHandler(processUpload))
	http.Handle("/blob2/serve-full", appstats.NewHandler(serveFull))
	http.Handle("/blob2/thumb", appstats.NewHandler(serveThumb))
	http.Handle("/blob2/rename-delete", appstats.NewHandler(renameOrDelete))
}
開發者ID:mehulsbhatt,項目名稱:tools-old,代碼行數:9,代碼來源:upload2.go

示例4: CreateHandler

func CreateHandler(handlerFunc func(appengine.Context, http.ResponseWriter, *http.Request)) appstats.Handler {
	return appstats.NewHandler(func(c appengine.Context, w http.ResponseWriter, r *http.Request) {
		headers := w.Header()
		headers.Set("X-Frame-Options", "SAMEORIGIN")
		headers.Set("X-XSS-Protection", "0")

		c.Infof("Request ID: %s", appengine.RequestID(c))

		handlerFunc(c, w, r)
	})
}
開發者ID:nightexcessive,項目名稱:netrack,代碼行數:11,代碼來源:http.go

示例5: Handler

//Handler maps standard net/http handlers to handlers accepting Context
func Handler(hand func(Context) error) http.Handler {
	return appstats.NewHandler(func(c appengine.Context, w http.ResponseWriter, r *http.Request) {
		vars := mux.Vars(r)
		context := Context{Context: c, W: w, R: r, Vars: vars}
		err := hand(context)
		if err != nil {
			c.Errorf("Error 500. %v", err)
			w.WriteHeader(http.StatusInternalServerError)
			RenderLayout("error.html", "Chyba", err, context)
		}
	})
}
開發者ID:sellweek,項目名稱:TOGY-server,代碼行數:13,代碼來源:util.go

示例6: init

func init() {
	http.Handle("/submit/map", appstats.NewHandler(submitMap))
	http.Handle("/submit/bulkUpdateUnique", appstats.NewHandler(submitBulkUpdateUnique))

	http.Handle("/batch/map", appstats.NewHandler(batchMap))
	http.Handle("/batch/couch", appstats.NewHandler(batchCouch))
	http.Handle("/batch/updateUnique", appstats.NewHandler(batchPrepareUnique))
	http.Handle("/batch/bulkUpdateUnique", appstats.NewHandler(batchBulkUpdateUnique))
	http.Handle("/batch/destroy", appstats.NewHandler(batchDestroy))
}
開發者ID:couchbaselabs,項目名稱:statstore,代碼行數:10,代碼來源:batch.go

示例7: NewHandler

// NewHandler returns a profiled, appstats-aware appengine.Context.
func NewHandler(f func(Context, http.ResponseWriter, *http.Request)) http.Handler {
	return appstats.NewHandler(func(c appengine.Context, w http.ResponseWriter, r *http.Request) {
		h := miniprofiler.NewHandler(func(t miniprofiler.Timer, w http.ResponseWriter, r *http.Request) {
			pc := Context{
				Context: c.(appstats.Context),
				Timer:   t,
			}
			t.SetName(miniprofiler.FuncName(f))
			f(pc, w, r)
			t.AddCustomLink("appstats", pc.URL())
		})
		h.ServeHTTP(w, r)
	})
}
開發者ID:jango2015,項目名稱:go,代碼行數:15,代碼來源:miniprofiler_gae.go

示例8: NewHandler

// NewHandler returns a profiled, appstats-aware appengine.Context.
func NewHandler(f func(Context, http.ResponseWriter, *http.Request)) appstats.Handler {
	return appstats.NewHandler(func(c appengine.Context, w http.ResponseWriter, r *http.Request) {
		pc := Context{
			Context: c.(appstats.Context),
		}
		pc.P = miniprofiler.NewProfile(w, r, miniprofiler.FuncName(f))
		f(pc, w, r)

		if pc.P.Root != nil {
			pc.P.CustomLink = pc.URL()
			pc.P.CustomLinkName = "appstats"
			pc.P.Finalize()
		}
	})
}
開發者ID:brycekahle,項目名稱:MiniProfiler,代碼行數:16,代碼來源:miniprofiler_gae.go

示例9: NewHandler

// NewHandler returns a profiled, appstats-aware appengine.Context.
func NewHandler(f func(Context, http.ResponseWriter, *http.Request)) appstats.Handler {
	return appstats.NewHandler(func(c appengine.Context, w http.ResponseWriter, r *http.Request) {
		h := miniprofiler.NewHandler(func(p *miniprofiler.Profile, w http.ResponseWriter, r *http.Request) {
			pc := Context{
				Context: c.(appstats.Context),
				Profile: p,
			}
			p.Name = miniprofiler.FuncName(f)
			f(pc, w, r)

			if pc.Profile.Root != nil {
				pc.Profile.CustomLink = pc.URL()
				pc.Profile.CustomLinkName = "appstats"
			}
		})
		h.ServeHTTP(w, r)
	})
}
開發者ID:krk,項目名稱:MiniProfiler,代碼行數:19,代碼來源:miniprofiler_gae.go

示例10: init

func init() {
	http.Handle("/users", appstats.NewHandler(users))
}
開發者ID:skiesel,項目名稱:mybrewcellar,代碼行數:3,代碼來源:users.go

示例11: init

func init() {
	http.Handle("/api/update-account", appstats.NewHandler(handleUpdateAccount))

	http.Handle("/api/new-cellar", appstats.NewHandler(handleNewCellarRequest))
	http.Handle("/api/delete-cellar", appstats.NewHandler(handleDeleteCellarRequest))
	http.Handle("/api/update-cellar", appstats.NewHandler(handleUpdateCellarRequest))

	http.Handle("/api/new-beer", appstats.NewHandler(handleNewBeerRequest))
	http.Handle("/api/delete-beer", appstats.NewHandler(handleDeleteBeerRequest))
	http.Handle("/api/transfer-beer", appstats.NewHandler(handleTransferBeerRequest))
	http.Handle("/api/update-beer", appstats.NewHandler(handleUpdateBeerRequest))

	http.Handle("/api/new-tasting", appstats.NewHandler(handleNewTastingRequest))
	http.Handle("/api/delete-tasting", appstats.NewHandler(handleDeleteTastingRequest))
	http.Handle("/api/update-tasting", appstats.NewHandler(handleUpdateTastingRequest))

	http.Handle("/api/get-qr-code", appstats.NewHandler(handleQRCodeRequest))
}
開發者ID:skiesel,項目名稱:mybrewcellar,代碼行數:18,代碼來源:api.go

示例12: init

func init() {
	http.Handle("/mycellars", appstats.NewHandler(mycellars))
}
開發者ID:skiesel,項目名稱:mybrewcellar,代碼行數:3,代碼來源:mycellars.go

示例13: init

func init() {
	http.Handle("/cellar", appstats.NewHandler(cellar))
}
開發者ID:skiesel,項目名稱:mybrewcellar,代碼行數:3,代碼來源:cellar.go

示例14: init

func init() {
	http.HandleFunc("/", front)
	http.Handle("/checkout", appstats.NewHandler(checkout))
	http.HandleFunc("/admin/populate", adminPopulate)
}
開發者ID:dsymonds,項目名稱:talks,代碼行數:5,代碼來源:mart.go

示例15: init

func init() {
	http.Handle("/updateUnique", appstats.NewHandler(processUpdateUnique))
}
開發者ID:couchbaselabs,項目名稱:statstore,代碼行數:3,代碼來源:update_unique.go


注:本文中的github.com/mjibson/appstats.NewHandler函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。