forked from devimteam/microgen
/
protobuf_endpoint_converters.microgen.go
276 lines (246 loc) · 8.56 KB
/
protobuf_endpoint_converters.microgen.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// Code generated by microgen 1.0.0-beta. DO NOT EDIT.
// Please, do not change functions names!
package transportgrpc
import (
"context"
"errors"
pb "github.com/devimteam/microgen/examples/protobuf"
transport "github.com/devimteam/microgen/examples/usersvc/pkg/transport"
empty "github.com/golang/protobuf/ptypes/empty"
)
func _Encode_CreateUser_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil CreateUserRequest")
}
req := request.(*transport.CreateUserRequest)
reqUser, err := UserToProto(req.User)
if err != nil {
return nil, err
}
return &pb.CreateUserRequest{User: reqUser}, nil
}
func _Encode_UpdateUser_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil UpdateUserRequest")
}
req := request.(*transport.UpdateUserRequest)
reqUser, err := UserToProto(req.User)
if err != nil {
return nil, err
}
return &pb.UpdateUserRequest{User: reqUser}, nil
}
func _Encode_GetUser_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil GetUserRequest")
}
req := request.(*transport.GetUserRequest)
return &pb.GetUserRequest{Id: req.Id}, nil
}
func _Encode_FindUsers_Request(ctx context.Context, request interface{}) (interface{}, error) {
return &empty.Empty{}, nil
}
func _Encode_CreateComment_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil CreateCommentRequest")
}
req := request.(*transport.CreateCommentRequest)
reqComment, err := CommentToProto(req.Comment)
if err != nil {
return nil, err
}
return &pb.CreateCommentRequest{Comment: reqComment}, nil
}
func _Encode_GetComment_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil GetCommentRequest")
}
req := request.(*transport.GetCommentRequest)
return &pb.GetCommentRequest{Id: req.Id}, nil
}
func _Encode_GetUserComments_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil GetUserCommentsRequest")
}
req := request.(*transport.GetUserCommentsRequest)
return &pb.GetUserCommentsRequest{UserId: req.UserId}, nil
}
func _Encode_CreateUser_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil CreateUserResponse")
}
resp := response.(*transport.CreateUserResponse)
return &pb.CreateUserResponse{Id: resp.Id}, nil
}
func _Encode_UpdateUser_Response(ctx context.Context, response interface{}) (interface{}, error) {
return &empty.Empty{}, nil
}
func _Encode_GetUser_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil GetUserResponse")
}
resp := response.(*transport.GetUserResponse)
respUser, err := UserToProto(resp.User)
if err != nil {
return nil, err
}
return &pb.GetUserResponse{User: respUser}, nil
}
func _Encode_FindUsers_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil FindUsersResponse")
}
resp := response.(*transport.FindUsersResponse)
respResults, err := MapStringUserToProto(resp.Results)
if err != nil {
return nil, err
}
return &pb.FindUsersResponse{Results: respResults}, nil
}
func _Encode_CreateComment_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil CreateCommentResponse")
}
resp := response.(*transport.CreateCommentResponse)
return &pb.CreateCommentResponse{Id: resp.Id}, nil
}
func _Encode_GetComment_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil GetCommentResponse")
}
resp := response.(*transport.GetCommentResponse)
respComment, err := CommentToProto(resp.Comment)
if err != nil {
return nil, err
}
return &pb.GetCommentResponse{Comment: respComment}, nil
}
func _Encode_GetUserComments_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil GetUserCommentsResponse")
}
resp := response.(*transport.GetUserCommentsResponse)
respList, err := ListCommentToProto(resp.List)
if err != nil {
return nil, err
}
return &pb.GetUserCommentsResponse{List: respList}, nil
}
func _Decode_CreateUser_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil CreateUserRequest")
}
req := request.(*pb.CreateUserRequest)
reqUser, err := ProtoToUser(req.User)
if err != nil {
return nil, err
}
return &transport.CreateUserRequest{User: reqUser}, nil
}
func _Decode_UpdateUser_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil UpdateUserRequest")
}
req := request.(*pb.UpdateUserRequest)
reqUser, err := ProtoToUser(req.User)
if err != nil {
return nil, err
}
return &transport.UpdateUserRequest{User: reqUser}, nil
}
func _Decode_GetUser_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil GetUserRequest")
}
req := request.(*pb.GetUserRequest)
return &transport.GetUserRequest{Id: string(req.Id)}, nil
}
func _Decode_FindUsers_Request(ctx context.Context, request interface{}) (interface{}, error) {
return &empty.Empty{}, nil
}
func _Decode_CreateComment_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil CreateCommentRequest")
}
req := request.(*pb.CreateCommentRequest)
reqComment, err := ProtoToComment(req.Comment)
if err != nil {
return nil, err
}
return &transport.CreateCommentRequest{Comment: reqComment}, nil
}
func _Decode_GetComment_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil GetCommentRequest")
}
req := request.(*pb.GetCommentRequest)
return &transport.GetCommentRequest{Id: string(req.Id)}, nil
}
func _Decode_GetUserComments_Request(ctx context.Context, request interface{}) (interface{}, error) {
if request == nil {
return nil, errors.New("nil GetUserCommentsRequest")
}
req := request.(*pb.GetUserCommentsRequest)
return &transport.GetUserCommentsRequest{UserId: string(req.UserId)}, nil
}
func _Decode_CreateUser_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil CreateUserResponse")
}
resp := response.(*pb.CreateUserResponse)
return &transport.CreateUserResponse{Id: string(resp.Id)}, nil
}
func _Decode_UpdateUser_Response(ctx context.Context, response interface{}) (interface{}, error) {
return &empty.Empty{}, nil
}
func _Decode_GetUser_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil GetUserResponse")
}
resp := response.(*pb.GetUserResponse)
respUser, err := ProtoToUser(resp.User)
if err != nil {
return nil, err
}
return &transport.GetUserResponse{User: respUser}, nil
}
func _Decode_FindUsers_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil FindUsersResponse")
}
resp := response.(*pb.FindUsersResponse)
respResults, err := ProtoToMapStringUser(resp.Results)
if err != nil {
return nil, err
}
return &transport.FindUsersResponse{Results: respResults}, nil
}
func _Decode_CreateComment_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil CreateCommentResponse")
}
resp := response.(*pb.CreateCommentResponse)
return &transport.CreateCommentResponse{Id: string(resp.Id)}, nil
}
func _Decode_GetComment_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil GetCommentResponse")
}
resp := response.(*pb.GetCommentResponse)
respComment, err := ProtoToComment(resp.Comment)
if err != nil {
return nil, err
}
return &transport.GetCommentResponse{Comment: respComment}, nil
}
func _Decode_GetUserComments_Response(ctx context.Context, response interface{}) (interface{}, error) {
if response == nil {
return nil, errors.New("nil GetUserCommentsResponse")
}
resp := response.(*pb.GetUserCommentsResponse)
respList, err := ProtoToListComment(resp.List)
if err != nil {
return nil, err
}
return &transport.GetUserCommentsResponse{List: respList}, nil
}