1
2
3
4
9 package examplepb
10
11 import (
12 "context"
13 "io"
14 "net/http"
15
16 "github.com/golang/protobuf/descriptor"
17 "github.com/golang/protobuf/proto"
18 "github.com/grpc-ecosystem/grpc-gateway/runtime"
19 "github.com/grpc-ecosystem/grpc-gateway/utilities"
20 "google.golang.org/grpc"
21 "google.golang.org/grpc/codes"
22 "google.golang.org/grpc/grpclog"
23 "google.golang.org/grpc/metadata"
24 "google.golang.org/grpc/status"
25 )
26
27
28 var _ codes.Code
29 var _ io.Reader
30 var _ status.Status
31 var _ = runtime.String
32 var _ = utilities.NewDoubleArray
33 var _ = descriptor.ForMessage
34 var _ = metadata.Join
35
36 var (
37 filter_UnannotatedEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
38 )
39
40 func request_UnannotatedEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
41 var protoReq UnannotatedSimpleMessage
42 var metadata runtime.ServerMetadata
43
44 var (
45 val string
46 ok bool
47 err error
48 _ = err
49 )
50
51 val, ok = pathParams["id"]
52 if !ok {
53 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
54 }
55
56 protoReq.Id, err = runtime.String(val)
57
58 if err != nil {
59 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
60 }
61
62 if err := req.ParseForm(); err != nil {
63 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
64 }
65 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_0); err != nil {
66 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
67 }
68
69 msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
70 return msg, metadata, err
71
72 }
73
74 func local_request_UnannotatedEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
75 var protoReq UnannotatedSimpleMessage
76 var metadata runtime.ServerMetadata
77
78 var (
79 val string
80 ok bool
81 err error
82 _ = err
83 )
84
85 val, ok = pathParams["id"]
86 if !ok {
87 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
88 }
89
90 protoReq.Id, err = runtime.String(val)
91
92 if err != nil {
93 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
94 }
95
96 if err := req.ParseForm(); err != nil {
97 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
98 }
99 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_0); err != nil {
100 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
101 }
102
103 msg, err := server.Echo(ctx, &protoReq)
104 return msg, metadata, err
105
106 }
107
108 var (
109 filter_UnannotatedEchoService_Echo_1 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}}
110 )
111
112 func request_UnannotatedEchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
113 var protoReq UnannotatedSimpleMessage
114 var metadata runtime.ServerMetadata
115
116 var (
117 val string
118 ok bool
119 err error
120 _ = err
121 )
122
123 val, ok = pathParams["id"]
124 if !ok {
125 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
126 }
127
128 protoReq.Id, err = runtime.String(val)
129
130 if err != nil {
131 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
132 }
133
134 val, ok = pathParams["num"]
135 if !ok {
136 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num")
137 }
138
139 protoReq.Num, err = runtime.Int64(val)
140
141 if err != nil {
142 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err)
143 }
144
145 if err := req.ParseForm(); err != nil {
146 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
147 }
148 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_1); err != nil {
149 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
150 }
151
152 msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
153 return msg, metadata, err
154
155 }
156
157 func local_request_UnannotatedEchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
158 var protoReq UnannotatedSimpleMessage
159 var metadata runtime.ServerMetadata
160
161 var (
162 val string
163 ok bool
164 err error
165 _ = err
166 )
167
168 val, ok = pathParams["id"]
169 if !ok {
170 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
171 }
172
173 protoReq.Id, err = runtime.String(val)
174
175 if err != nil {
176 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
177 }
178
179 val, ok = pathParams["num"]
180 if !ok {
181 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num")
182 }
183
184 protoReq.Num, err = runtime.Int64(val)
185
186 if err != nil {
187 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err)
188 }
189
190 if err := req.ParseForm(); err != nil {
191 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
192 }
193 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_1); err != nil {
194 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
195 }
196
197 msg, err := server.Echo(ctx, &protoReq)
198 return msg, metadata, err
199
200 }
201
202 func request_UnannotatedEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
203 var protoReq UnannotatedSimpleMessage
204 var metadata runtime.ServerMetadata
205
206 newReader, berr := utilities.IOReaderFactory(req.Body)
207 if berr != nil {
208 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
209 }
210 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
211 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
212 }
213
214 msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
215 return msg, metadata, err
216
217 }
218
219 func local_request_UnannotatedEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
220 var protoReq UnannotatedSimpleMessage
221 var metadata runtime.ServerMetadata
222
223 newReader, berr := utilities.IOReaderFactory(req.Body)
224 if berr != nil {
225 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
226 }
227 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
228 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
229 }
230
231 msg, err := server.EchoBody(ctx, &protoReq)
232 return msg, metadata, err
233
234 }
235
236 var (
237 filter_UnannotatedEchoService_EchoDelete_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
238 )
239
240 func request_UnannotatedEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
241 var protoReq UnannotatedSimpleMessage
242 var metadata runtime.ServerMetadata
243
244 if err := req.ParseForm(); err != nil {
245 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
246 }
247 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_EchoDelete_0); err != nil {
248 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
249 }
250
251 msg, err := client.EchoDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
252 return msg, metadata, err
253
254 }
255
256 func local_request_UnannotatedEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
257 var protoReq UnannotatedSimpleMessage
258 var metadata runtime.ServerMetadata
259
260 if err := req.ParseForm(); err != nil {
261 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
262 }
263 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_EchoDelete_0); err != nil {
264 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
265 }
266
267 msg, err := server.EchoDelete(ctx, &protoReq)
268 return msg, metadata, err
269
270 }
271
272
273
274
275
276 func RegisterUnannotatedEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UnannotatedEchoServiceServer) error {
277
278 mux.Handle("POST", pattern_UnannotatedEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
279 ctx, cancel := context.WithCancel(req.Context())
280 defer cancel()
281 var stream runtime.ServerTransportStream
282 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
283 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
284 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
285 if err != nil {
286 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
287 return
288 }
289 resp, md, err := local_request_UnannotatedEchoService_Echo_0(rctx, inboundMarshaler, server, req, pathParams)
290 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
291 ctx = runtime.NewServerMetadataContext(ctx, md)
292 if err != nil {
293 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
294 return
295 }
296
297 forward_UnannotatedEchoService_Echo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
298
299 })
300
301 mux.Handle("GET", pattern_UnannotatedEchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
302 ctx, cancel := context.WithCancel(req.Context())
303 defer cancel()
304 var stream runtime.ServerTransportStream
305 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
306 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
307 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
308 if err != nil {
309 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
310 return
311 }
312 resp, md, err := local_request_UnannotatedEchoService_Echo_1(rctx, inboundMarshaler, server, req, pathParams)
313 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
314 ctx = runtime.NewServerMetadataContext(ctx, md)
315 if err != nil {
316 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
317 return
318 }
319
320 forward_UnannotatedEchoService_Echo_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
321
322 })
323
324 mux.Handle("POST", pattern_UnannotatedEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
325 ctx, cancel := context.WithCancel(req.Context())
326 defer cancel()
327 var stream runtime.ServerTransportStream
328 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
329 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
330 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
331 if err != nil {
332 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
333 return
334 }
335 resp, md, err := local_request_UnannotatedEchoService_EchoBody_0(rctx, inboundMarshaler, server, req, pathParams)
336 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
337 ctx = runtime.NewServerMetadataContext(ctx, md)
338 if err != nil {
339 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
340 return
341 }
342
343 forward_UnannotatedEchoService_EchoBody_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
344
345 })
346
347 mux.Handle("DELETE", pattern_UnannotatedEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
348 ctx, cancel := context.WithCancel(req.Context())
349 defer cancel()
350 var stream runtime.ServerTransportStream
351 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
352 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
353 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
354 if err != nil {
355 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
356 return
357 }
358 resp, md, err := local_request_UnannotatedEchoService_EchoDelete_0(rctx, inboundMarshaler, server, req, pathParams)
359 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
360 ctx = runtime.NewServerMetadataContext(ctx, md)
361 if err != nil {
362 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
363 return
364 }
365
366 forward_UnannotatedEchoService_EchoDelete_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
367
368 })
369
370 return nil
371 }
372
373
374
375 func RegisterUnannotatedEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
376 conn, err := grpc.Dial(endpoint, opts...)
377 if err != nil {
378 return err
379 }
380 defer func() {
381 if err != nil {
382 if cerr := conn.Close(); cerr != nil {
383 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
384 }
385 return
386 }
387 go func() {
388 <-ctx.Done()
389 if cerr := conn.Close(); cerr != nil {
390 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
391 }
392 }()
393 }()
394
395 return RegisterUnannotatedEchoServiceHandler(ctx, mux, conn)
396 }
397
398
399
400 func RegisterUnannotatedEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
401 return RegisterUnannotatedEchoServiceHandlerClient(ctx, mux, NewUnannotatedEchoServiceClient(conn))
402 }
403
404
405
406
407
408
409 func RegisterUnannotatedEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UnannotatedEchoServiceClient) error {
410
411 mux.Handle("POST", pattern_UnannotatedEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
412 ctx, cancel := context.WithCancel(req.Context())
413 defer cancel()
414 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
415 rctx, err := runtime.AnnotateContext(ctx, mux, req)
416 if err != nil {
417 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
418 return
419 }
420 resp, md, err := request_UnannotatedEchoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams)
421 ctx = runtime.NewServerMetadataContext(ctx, md)
422 if err != nil {
423 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
424 return
425 }
426
427 forward_UnannotatedEchoService_Echo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
428
429 })
430
431 mux.Handle("GET", pattern_UnannotatedEchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
432 ctx, cancel := context.WithCancel(req.Context())
433 defer cancel()
434 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
435 rctx, err := runtime.AnnotateContext(ctx, mux, req)
436 if err != nil {
437 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
438 return
439 }
440 resp, md, err := request_UnannotatedEchoService_Echo_1(rctx, inboundMarshaler, client, req, pathParams)
441 ctx = runtime.NewServerMetadataContext(ctx, md)
442 if err != nil {
443 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
444 return
445 }
446
447 forward_UnannotatedEchoService_Echo_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
448
449 })
450
451 mux.Handle("POST", pattern_UnannotatedEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
452 ctx, cancel := context.WithCancel(req.Context())
453 defer cancel()
454 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
455 rctx, err := runtime.AnnotateContext(ctx, mux, req)
456 if err != nil {
457 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
458 return
459 }
460 resp, md, err := request_UnannotatedEchoService_EchoBody_0(rctx, inboundMarshaler, client, req, pathParams)
461 ctx = runtime.NewServerMetadataContext(ctx, md)
462 if err != nil {
463 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
464 return
465 }
466
467 forward_UnannotatedEchoService_EchoBody_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
468
469 })
470
471 mux.Handle("DELETE", pattern_UnannotatedEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
472 ctx, cancel := context.WithCancel(req.Context())
473 defer cancel()
474 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
475 rctx, err := runtime.AnnotateContext(ctx, mux, req)
476 if err != nil {
477 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
478 return
479 }
480 resp, md, err := request_UnannotatedEchoService_EchoDelete_0(rctx, inboundMarshaler, client, req, pathParams)
481 ctx = runtime.NewServerMetadataContext(ctx, md)
482 if err != nil {
483 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
484 return
485 }
486
487 forward_UnannotatedEchoService_EchoDelete_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
488
489 })
490
491 return nil
492 }
493
494 var (
495 pattern_UnannotatedEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo", "id"}, "", runtime.AssumeColonVerbOpt(true)))
496
497 pattern_UnannotatedEchoService_Echo_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "echo", "id", "num"}, "", runtime.AssumeColonVerbOpt(true)))
498
499 pattern_UnannotatedEchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_body"}, "", runtime.AssumeColonVerbOpt(true)))
500
501 pattern_UnannotatedEchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_delete"}, "", runtime.AssumeColonVerbOpt(true)))
502 )
503
504 var (
505 forward_UnannotatedEchoService_Echo_0 = runtime.ForwardResponseMessage
506
507 forward_UnannotatedEchoService_Echo_1 = runtime.ForwardResponseMessage
508
509 forward_UnannotatedEchoService_EchoBody_0 = runtime.ForwardResponseMessage
510
511 forward_UnannotatedEchoService_EchoDelete_0 = runtime.ForwardResponseMessage
512 )
513
View as plain text