/
code.lug.pb.go
134 lines (128 loc) · 4.17 KB
/
code.lug.pb.go
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Code generated by protoc-gen-lug. DO NOT EDIT.
// versions:
// - protoc-gen-lug v0.1.0
// - protoc v3.17.3
// source: proto/login/code.proto
package login
import (
fiber "github.com/pubgo/lug/pkg/builder/fiber"
grpcc "github.com/pubgo/lug/plugins/grpcc"
xgen "github.com/pubgo/lug/xgen"
xerror "github.com/pubgo/xerror"
grpc "google.golang.org/grpc"
reflect "reflect"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
func GetCodeClient(srv string, opts ...func(cfg *grpcc.Cfg)) func(func(cli CodeClient)) error {
client := grpcc.GetClient(srv, opts...)
return func(fn func(cli CodeClient)) (err error) {
defer xerror.RespErr(&err)
c, err := client.Get()
if err != nil {
return xerror.WrapF(err, "srv: %s", srv)
}
fn(&codeClient{c})
return
}
}
func init() {
var mthList []xgen.GrpcRestHandler
mthList = append(mthList, xgen.GrpcRestHandler{
Input: &SendCodeRequest{},
Output: &SendCodeResponse{},
Service: "login.Code",
Name: "SendCode",
Method: "POST",
Path: "/user/code/send-code",
DefaultUrl: false,
ClientStream: false,
ServerStream: false,
})
mthList = append(mthList, xgen.GrpcRestHandler{
Input: &VerifyRequest{},
Output: &VerifyResponse{},
Service: "login.Code",
Name: "Verify",
Method: "POST",
Path: "/user/code/verify",
DefaultUrl: false,
ClientStream: false,
ServerStream: false,
})
mthList = append(mthList, xgen.GrpcRestHandler{
Input: &IsCheckImageCodeRequest{},
Output: &IsCheckImageCodeResponse{},
Service: "login.Code",
Name: "IsCheckImageCode",
Method: "POST",
Path: "/user/code/is-check-image-code",
DefaultUrl: false,
ClientStream: false,
ServerStream: false,
})
mthList = append(mthList, xgen.GrpcRestHandler{
Input: &VerifyImageCodeRequest{},
Output: &VerifyImageCodeResponse{},
Service: "login.Code",
Name: "VerifyImageCode",
Method: "POST",
Path: "/user/code/verify-image-code",
DefaultUrl: false,
ClientStream: false,
ServerStream: false,
})
mthList = append(mthList, xgen.GrpcRestHandler{
Input: &GetSendStatusRequest{},
Output: &GetSendStatusResponse{},
Service: "login.Code",
Name: "GetSendStatus",
Method: "POST",
Path: "/user/code/get-send-status",
DefaultUrl: false,
ClientStream: false,
ServerStream: false,
})
xgen.Add(reflect.ValueOf(RegisterCodeServer), mthList)
xgen.Add(reflect.ValueOf(RegisterCodeHandlerServer), nil)
}
func RegisterCodeRestServer(app fiber.Router, server CodeServer) {
xerror.Assert(app == nil || server == nil, "app is nil or server is nil")
app.Add("POST", "/user/code/send-code", func(ctx *fiber.Ctx) error {
var req = new(SendCodeRequest)
xerror.Panic(ctx.BodyParser(req))
var resp, err = server.SendCode(ctx.UserContext(), req)
xerror.Panic(err)
return xerror.Wrap(ctx.JSON(resp))
})
app.Add("POST", "/user/code/verify", func(ctx *fiber.Ctx) error {
var req = new(VerifyRequest)
xerror.Panic(ctx.BodyParser(req))
var resp, err = server.Verify(ctx.UserContext(), req)
xerror.Panic(err)
return xerror.Wrap(ctx.JSON(resp))
})
app.Add("POST", "/user/code/is-check-image-code", func(ctx *fiber.Ctx) error {
var req = new(IsCheckImageCodeRequest)
xerror.Panic(ctx.BodyParser(req))
var resp, err = server.IsCheckImageCode(ctx.UserContext(), req)
xerror.Panic(err)
return xerror.Wrap(ctx.JSON(resp))
})
app.Add("POST", "/user/code/verify-image-code", func(ctx *fiber.Ctx) error {
var req = new(VerifyImageCodeRequest)
xerror.Panic(ctx.BodyParser(req))
var resp, err = server.VerifyImageCode(ctx.UserContext(), req)
xerror.Panic(err)
return xerror.Wrap(ctx.JSON(resp))
})
app.Add("POST", "/user/code/get-send-status", func(ctx *fiber.Ctx) error {
var req = new(GetSendStatusRequest)
xerror.Panic(ctx.BodyParser(req))
var resp, err = server.GetSendStatus(ctx.UserContext(), req)
xerror.Panic(err)
return xerror.Wrap(ctx.JSON(resp))
})
}