Repository navigation
Expand file tree
/
Copy pathtest_handler.go
More file actions
59 lines (49 loc) · 1.51 KB
/
Copy pathtest_handler.go
File metadata and controls
59 lines (49 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package service
import (
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
airdrop "github.com/keybase/client/go/stellar/airdrop"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
"golang.org/x/net/context"
)
type TestHandler struct {
*BaseHandler
libkb.Contextified
}
func NewTestHandler(xp rpc.Transporter, g *libkb.GlobalContext) *TestHandler {
return &TestHandler{
BaseHandler: NewBaseHandler(g, xp),
Contextified: libkb.NewContextified(g),
}
}
func (t TestHandler) Test(ctx context.Context, arg keybase1.TestArg) (test keybase1.Test, err error) {
client := t.rpcClient()
cbArg := keybase1.TestCallbackArg(arg)
var cbReply string
err = client.Call(ctx, "keybase.1.test.testCallback", []interface{}{cbArg}, &cbReply, 0)
if err != nil {
return
}
test.Reply = cbReply
return
}
func (t TestHandler) TestCallback(_ context.Context, arg keybase1.TestCallbackArg) (s string, err error) {
return
}
func (t TestHandler) Panic(_ context.Context, message string) error {
t.G().Log.Info("Received panic() RPC")
go func() {
panic(message)
}()
return nil
}
func (t TestHandler) TestAirdropReg(ctx context.Context) error {
mctx := libkb.NewMetaContext(ctx, t.G()).WithLogTag("ADREG")
cli := airdrop.NewClient()
return cli.Register(mctx)
}
func (t TestHandler) Echo(ctx context.Context, arg keybase1.Generic) (keybase1.Generic, error) {
return arg, nil
}