Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: appengine/ephelper/context.go

Issue 1750143003: Remove ephelper and other endpoints code. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/ephelper/assertions/errors.go ('k') | appengine/ephelper/epfrontend/discovery.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/ephelper/context.go
diff --git a/appengine/ephelper/context.go b/appengine/ephelper/context.go
deleted file mode 100644
index ff1c60e132bb181b2b49953ad4d596e42d4e6e94..0000000000000000000000000000000000000000
--- a/appengine/ephelper/context.go
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package ephelper
-
-import (
- "fmt"
-
- "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
- "golang.org/x/net/context"
-)
-
-type serviceCallKeyType int
-
-var serviceCallKey serviceCallKeyType
-
-type serviceCall struct {
- mi *endpoints.MethodInfo
-}
-
-// ServiceBase is an embeddable base class for endpoints services.
-//
-// Example:
-//
-// type MyService struct {
-// *ServiceBase
-// }
-//
-// func (s *MyService) MyCoolEndpoint(c context.Context) error {
-// c, err = s.Use(c, myMethodInfo)
-// if err != nil {
-// return err
-// }
-// ...
-// }
-type ServiceBase struct {
- // Middleware is the set of middleware context manipulators to run for this
- // service.
- //
- // If nil, the middleware stack returned by DefaultMiddleware will be used.
- Middleware []Middleware
-}
-
-// Use should be called at the beginning of a Cloud Endpoint handler to
-// initialize the handler's baseline Context and authenticate the call.
-func (s *ServiceBase) Use(c context.Context, mi *endpoints.MethodInfo) (context.Context, error) {
- // In case the developer forgot to set it...
- if s == nil {
- return c, fmt.Errorf("no ServiceBase is configured for: %#v", mi)
- }
-
- // Embed our service context.
- sc := serviceCall{
- mi: mi,
- }
- c = context.WithValue(c, serviceCallKey, &sc)
-
- middleware := s.Middleware
- if middleware == nil {
- middleware = []Middleware{DefaultMiddleware(nil)}
- }
- for _, mw := range middleware {
- ic, err := mw(c)
- if err != nil {
- return c, err
- }
- c = ic
- }
-
- return c, nil
-}
-
-// MethodInfo returns the endpoints.MethodInfo for the current service call.
-func MethodInfo(c context.Context) *endpoints.MethodInfo {
- if sc, ok := c.Value(serviceCallKey).(*serviceCall); ok {
- return sc.mi
- }
- return nil
-}
« no previous file with comments | « appengine/ephelper/assertions/errors.go ('k') | appengine/ephelper/epfrontend/discovery.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698