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

Unified Diff: go/src/infra/gae/epservice/example/service_list.go

Issue 1153473008: A client/server helper wrapper for endpoints in Go. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: rm newline Created 5 years, 6 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
Index: go/src/infra/gae/epservice/example/service_list.go
diff --git a/go/src/infra/gae/epservice/example/service_list.go b/go/src/infra/gae/epservice/example/service_list.go
new file mode 100644
index 0000000000000000000000000000000000000000..9e8df9c3ed819e31997f8647a756571d68381940
--- /dev/null
+++ b/go/src/infra/gae/epservice/example/service_list.go
@@ -0,0 +1,38 @@
+// 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 example
+
+import (
+ "golang.org/x/net/context"
+ "infra/gae/libs/wrapper"
+ "infra/gae/libs/wrapper/gae"
+
+ "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
+)
+
+// ListRsp is the response from the 'List' RPC. It contains a list of Counters
+// including their IDs and Values.
+type ListRsp struct {
+ Counters []Counter
+}
+
+// List returns a list of all the counters. Note that it's very poorly
+// implemented! It's completely unpaged. I don't care :).
+func (Example) List(c endpoints.Context) (rsp *ListRsp, err error) {
+ ds := wrapper.GetDS(gae.Use(context.Background(), c))
+ rsp = &ListRsp{}
+ _, err = ds.GetAll(ds.NewQuery("Counter"), &rsp.Counters)
+ if err != nil {
+ return
+ }
+ return
+}
+
+func init() {
+ mi["List"] = &endpoints.MethodInfo{
+ Path: "counter",
+ Desc: "Returns all of the available counters",
+ }
+}
« no previous file with comments | « go/src/infra/gae/epservice/example/service_currentvalue.go ('k') | go/src/infra/gae/libs/ephelper/ephelper.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698