Exemplo n.º 1
0
func setAppEngineContext(next alice.ContextHandler) alice.ContextHandler {
	fn := func(empty appContext.Context, w http.ResponseWriter, r *http.Request) {
		// we hang on our empty parent context the appengine context for further middlewares
		newContext := appengine.WithContext(empty, r)
		next.ServeHTTPContext(newContext, w, r)
	}
	return alice.ContextHandlerFunc(fn)
}
Exemplo n.º 2
0
// ContextMiddleware bootstraps the context to be able to contact with App Engine.
func ContextMiddleware(ctx context.Context, w http.ResponseWriter, r *http.Request, next NextMiddlewareFn) error {
	return next(appengine.WithContext(ctx, r))
}