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

Side by Side Diff: appengine/apigen_examples/dumb_counter/dumbCounter/service_currentvalue.go

Issue 1750143003: Remove ephelper and other endpoints code. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 9 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 dumbCounter
6
7 import (
8 "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
9 dstore "github.com/luci/gae/service/datastore"
10 "golang.org/x/net/context"
11 )
12
13 // CurrentValueReq describes the inputs to the CurrentValueReq RPC.
14 type CurrentValueReq struct {
15 Name string `endpoints:"required"`
16 }
17
18 // CurrentValueRsp describes the outputs of the CurrentValueReq RPC.
19 type CurrentValueRsp struct {
20 Val int64 `json:",string"`
21 }
22
23 // CurrentValue gets the current value of a counter (duh)
24 func (e *Example) CurrentValue(c context.Context, r *CurrentValueReq) (rsp *Curr entValueRsp, err error) {
25 c, err = e.Use(c, currentValueMethodInfo)
26 if err != nil {
27 return
28 }
29
30 ds := dstore.Get(c)
31
32 ctr := &Counter{Name: r.Name}
33 if err = ds.Get(ctr); err != nil {
34 return
35 }
36
37 rsp = &CurrentValueRsp{ctr.Val}
38 return
39 }
40
41 var currentValueMethodInfo = &endpoints.MethodInfo{
42 Path: "counter/{Name}",
43 Desc: "Returns the current value held by the named counter",
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698