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

Side by Side Diff: go/src/infra/gae/epservice/example/service_currentvalue.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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package example
6
7 import (
8 "golang.org/x/net/context"
9 "infra/gae/libs/wrapper"
10 "infra/gae/libs/wrapper/gae"
11
12 "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
13 )
14
15 // CurrentValueReq describes the inputs to the CurrentValueReq RPC.
16 type CurrentValueReq struct {
17 Name string `endpoints:"required"`
18 }
19
20 // CurrentValueRsp describes the outputs of the CurrentValueReq RPC.
21 type CurrentValueRsp struct {
22 Val int64 `json:",string"`
23 }
24
25 // CurrentValue gets the current value of a counter (duh)
26 func (Example) CurrentValue(c endpoints.Context, r *CurrentValueReq) (rsp *Curre ntValueRsp, err error) {
27 ds := wrapper.GetDS(gae.Use(context.Background(), c))
28
29 ctr := &Counter{ID: r.Name}
30 if err = ds.Get(ctr); err != nil {
31 return
32 }
33
34 rsp = &CurrentValueRsp{ctr.Val}
35 return
36 }
37
38 func init() {
39 mi["CurrentValue"] = &endpoints.MethodInfo{
40 Path: "counter/{Name}",
41 Desc: "Returns the current value held by the named counter",
42 }
43 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/epservice/example/service_cas.go ('k') | go/src/infra/gae/epservice/example/service_list.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698