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

Unified Diff: appengine/ephelper/ephelper.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/epfrontend/util_test.go ('k') | appengine/ephelper/errors.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/ephelper/ephelper.go
diff --git a/appengine/ephelper/ephelper.go b/appengine/ephelper/ephelper.go
deleted file mode 100644
index 7cb5ffe6855c9df78d57b22ba3cbc2ccbb893687..0000000000000000000000000000000000000000
--- a/appengine/ephelper/ephelper.go
+++ /dev/null
@@ -1,102 +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 (
- "errors"
- "fmt"
-
- "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
- "github.com/luci/luci-go/appengine/ephelper/epfrontend"
-)
-
-const errPrefix = "endpoints.Register: "
-
-var (
- // ErrServerNil is returned if you pass a nil server to Register. Don't do
- // that.
- ErrServerNil = errors.New(errPrefix + "server is nil")
-
- // ErrServiceNil is returned if you pass a nil service to Register. Don't do
- // that.
- ErrServiceNil = errors.New(errPrefix + "service is nil")
-
- // DefaultHelper is the default Helper implementation.
- DefaultHelper = Helper{}
-)
-
-// MethodInfoMap is the common registry for an endpoints service. It's
-// used by infra/libs/endpoints_client to populate its API.
-type MethodInfoMap map[string]*endpoints.MethodInfo
-
-// Helper is the endpoint helper configuration.
-type Helper struct {
- // Frontend is the internally-hosted endpoints frontend service.
- //
- // If not nil, calls to Register() will also register the resulting
- // services with the Frontend instance.
- Frontend *epfrontend.Server
-}
-
-// Register adds an endpoints.RegisterService-compatible service object using
-// the MethodInfoMap to look up the MethodInfo objects by methodName. It is
-// intended to be called at init()-time of an app or client which relies on
-// these endpoints.
-//
-// service should be an instance of your service type (as if you were passing
-// it to "go-endpoints/endpoints".RegisterService).
-func (h *Helper) Register(server *endpoints.Server, service interface{}, si *endpoints.ServiceInfo,
- mi MethodInfoMap) error {
- if server == nil {
- return ErrServerNil
- }
- if service == nil {
- return ErrServiceNil
- }
- if si == nil {
- si = &endpoints.ServiceInfo{Default: true}
- }
-
- api, err := server.RegisterService(service, si.Name, si.Version,
- si.Description, si.Default)
- if err != nil {
- return err
- }
-
- for methodName, info := range mi {
- method := api.MethodByName(methodName)
- if method == nil {
- return fmt.Errorf(
- errPrefix+"no method %q (did you forget to export it?)", methodName)
- }
- curInfo := method.Info()
- // These three are set automatically based on reflection, so only override
- // them if the info object contains something new.
- if info.Name == "" {
- info.Name = curInfo.Name
- }
- if info.Path == "" {
- info.Path = curInfo.Path
- }
- if info.HTTPMethod == "" {
- info.HTTPMethod = curInfo.HTTPMethod
- }
- *curInfo = *info
- mi[methodName] = curInfo // So that we can observe the merged result
- }
-
- if h.Frontend != nil {
- if err := h.Frontend.RegisterService(api); err != nil {
- return fmt.Errorf("%s: failed to register with frontend: %v", errPrefix, err)
- }
- }
- return nil
-}
-
-// Register is a convenience method to pass through registration to the
-// DefaultHelper.
-func Register(server *endpoints.Server, service interface{}, si *endpoints.ServiceInfo, mi MethodInfoMap) error {
- return DefaultHelper.Register(server, service, si, mi)
-}
« no previous file with comments | « appengine/ephelper/epfrontend/util_test.go ('k') | appengine/ephelper/errors.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698