You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

demo.pb.gw.go 6.5 kB

3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
  2. // source: idl/demo/demo.proto
  3. /*
  4. Package demo is a reverse proxy.
  5. It translates gRPC into RESTful JSON APIs.
  6. */
  7. package demo
  8. import (
  9. "context"
  10. "io"
  11. "net/http"
  12. "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
  13. "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
  14. "google.golang.org/grpc"
  15. "google.golang.org/grpc/codes"
  16. "google.golang.org/grpc/grpclog"
  17. "google.golang.org/grpc/metadata"
  18. "google.golang.org/grpc/status"
  19. "google.golang.org/protobuf/proto"
  20. )
  21. // Suppress "imported and not used" errors
  22. var _ codes.Code
  23. var _ io.Reader
  24. var _ status.Status
  25. var _ = runtime.String
  26. var _ = utilities.NewDoubleArray
  27. var _ = metadata.Join
  28. func request_DemoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client DemoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  29. var protoReq StringMessage
  30. var metadata runtime.ServerMetadata
  31. newReader, berr := utilities.IOReaderFactory(req.Body)
  32. if berr != nil {
  33. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
  34. }
  35. if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
  36. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  37. }
  38. msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  39. return msg, metadata, err
  40. }
  41. func local_request_DemoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server DemoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  42. var protoReq StringMessage
  43. var metadata runtime.ServerMetadata
  44. newReader, berr := utilities.IOReaderFactory(req.Body)
  45. if berr != nil {
  46. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
  47. }
  48. if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
  49. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  50. }
  51. msg, err := server.Echo(ctx, &protoReq)
  52. return msg, metadata, err
  53. }
  54. // RegisterDemoServiceHandlerServer registers the http handlers for service DemoService to "mux".
  55. // UnaryRPC :call DemoServiceServer directly.
  56. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
  57. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDemoServiceHandlerFromEndpoint instead.
  58. func RegisterDemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DemoServiceServer) error {
  59. mux.Handle("POST", pattern_DemoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  60. ctx, cancel := context.WithCancel(req.Context())
  61. defer cancel()
  62. var stream runtime.ServerTransportStream
  63. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  64. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  65. var err error
  66. ctx, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo"))
  67. if err != nil {
  68. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  69. return
  70. }
  71. resp, md, err := local_request_DemoService_Echo_0(ctx, inboundMarshaler, server, req, pathParams)
  72. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  73. ctx = runtime.NewServerMetadataContext(ctx, md)
  74. if err != nil {
  75. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  76. return
  77. }
  78. forward_DemoService_Echo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  79. })
  80. return nil
  81. }
  82. // RegisterDemoServiceHandlerFromEndpoint is same as RegisterDemoServiceHandler but
  83. // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
  84. func RegisterDemoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
  85. conn, err := grpc.Dial(endpoint, opts...)
  86. if err != nil {
  87. return err
  88. }
  89. defer func() {
  90. if err != nil {
  91. if cerr := conn.Close(); cerr != nil {
  92. grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
  93. }
  94. return
  95. }
  96. go func() {
  97. <-ctx.Done()
  98. if cerr := conn.Close(); cerr != nil {
  99. grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
  100. }
  101. }()
  102. }()
  103. return RegisterDemoServiceHandler(ctx, mux, conn)
  104. }
  105. // RegisterDemoServiceHandler registers the http handlers for service DemoService to "mux".
  106. // The handlers forward requests to the grpc endpoint over "conn".
  107. func RegisterDemoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
  108. return RegisterDemoServiceHandlerClient(ctx, mux, NewDemoServiceClient(conn))
  109. }
  110. // RegisterDemoServiceHandlerClient registers the http handlers for service DemoService
  111. // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DemoServiceClient".
  112. // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DemoServiceClient"
  113. // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
  114. // "DemoServiceClient" to call the correct interceptors.
  115. func RegisterDemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DemoServiceClient) error {
  116. mux.Handle("POST", pattern_DemoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  117. ctx, cancel := context.WithCancel(req.Context())
  118. defer cancel()
  119. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  120. var err error
  121. ctx, err = runtime.AnnotateContext(ctx, mux, req, "/demo.DemoService/Echo", runtime.WithHTTPPathPattern("/apis/demo"))
  122. if err != nil {
  123. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  124. return
  125. }
  126. resp, md, err := request_DemoService_Echo_0(ctx, inboundMarshaler, client, req, pathParams)
  127. ctx = runtime.NewServerMetadataContext(ctx, md)
  128. if err != nil {
  129. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  130. return
  131. }
  132. forward_DemoService_Echo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  133. })
  134. return nil
  135. }
  136. var (
  137. pattern_DemoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"apis", "demo"}, ""))
  138. )
  139. var (
  140. forward_DemoService_Echo_0 = runtime.ForwardResponseMessage
  141. )

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.