github.com/s7techlab/cckit@v0.10.5/extensions/pinger/chaincode_pinger.pb.gw.go (about) 1 // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. 2 // source: pinger/chaincode_pinger.proto 3 4 /* 5 Package pinger is a reverse proxy. 6 7 It translates gRPC into RESTful JSON APIs. 8 */ 9 package pinger 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 "google.golang.org/protobuf/types/known/emptypb" 26 ) 27 28 // Suppress "imported and not used" errors 29 var _ codes.Code 30 var _ io.Reader 31 var _ status.Status 32 var _ = runtime.String 33 var _ = utilities.NewDoubleArray 34 var _ = descriptor.ForMessage 35 var _ = metadata.Join 36 37 func request_ChaincodePingerService_Ping_0(ctx context.Context, marshaler runtime.Marshaler, client ChaincodePingerServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 38 var protoReq emptypb.Empty 39 var metadata runtime.ServerMetadata 40 41 newReader, berr := utilities.IOReaderFactory(req.Body) 42 if berr != nil { 43 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) 44 } 45 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { 46 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 47 } 48 49 msg, err := client.Ping(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 50 return msg, metadata, err 51 52 } 53 54 func local_request_ChaincodePingerService_Ping_0(ctx context.Context, marshaler runtime.Marshaler, server ChaincodePingerServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 55 var protoReq emptypb.Empty 56 var metadata runtime.ServerMetadata 57 58 newReader, berr := utilities.IOReaderFactory(req.Body) 59 if berr != nil { 60 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) 61 } 62 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { 63 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 64 } 65 66 msg, err := server.Ping(ctx, &protoReq) 67 return msg, metadata, err 68 69 } 70 71 // RegisterChaincodePingerServiceHandlerServer registers the http handlers for service ChaincodePingerService to "mux". 72 // UnaryRPC :call ChaincodePingerServiceServer directly. 73 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 74 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterChaincodePingerServiceHandlerFromEndpoint instead. 75 func RegisterChaincodePingerServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChaincodePingerServiceServer) error { 76 77 mux.Handle("POST", pattern_ChaincodePingerService_Ping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 78 ctx, cancel := context.WithCancel(req.Context()) 79 defer cancel() 80 var stream runtime.ServerTransportStream 81 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 82 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 83 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) 84 if err != nil { 85 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 86 return 87 } 88 resp, md, err := local_request_ChaincodePingerService_Ping_0(rctx, inboundMarshaler, server, req, pathParams) 89 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 90 ctx = runtime.NewServerMetadataContext(ctx, md) 91 if err != nil { 92 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 93 return 94 } 95 96 forward_ChaincodePingerService_Ping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 97 98 }) 99 100 return nil 101 } 102 103 // RegisterChaincodePingerServiceHandlerFromEndpoint is same as RegisterChaincodePingerServiceHandler but 104 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 105 func RegisterChaincodePingerServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 106 conn, err := grpc.Dial(endpoint, opts...) 107 if err != nil { 108 return err 109 } 110 defer func() { 111 if err != nil { 112 if cerr := conn.Close(); cerr != nil { 113 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 114 } 115 return 116 } 117 go func() { 118 <-ctx.Done() 119 if cerr := conn.Close(); cerr != nil { 120 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 121 } 122 }() 123 }() 124 125 return RegisterChaincodePingerServiceHandler(ctx, mux, conn) 126 } 127 128 // RegisterChaincodePingerServiceHandler registers the http handlers for service ChaincodePingerService to "mux". 129 // The handlers forward requests to the grpc endpoint over "conn". 130 func RegisterChaincodePingerServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 131 return RegisterChaincodePingerServiceHandlerClient(ctx, mux, NewChaincodePingerServiceClient(conn)) 132 } 133 134 // RegisterChaincodePingerServiceHandlerClient registers the http handlers for service ChaincodePingerService 135 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChaincodePingerServiceClient". 136 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChaincodePingerServiceClient" 137 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 138 // "ChaincodePingerServiceClient" to call the correct interceptors. 139 func RegisterChaincodePingerServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChaincodePingerServiceClient) error { 140 141 mux.Handle("POST", pattern_ChaincodePingerService_Ping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 142 ctx, cancel := context.WithCancel(req.Context()) 143 defer cancel() 144 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 145 rctx, err := runtime.AnnotateContext(ctx, mux, req) 146 if err != nil { 147 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 148 return 149 } 150 resp, md, err := request_ChaincodePingerService_Ping_0(rctx, inboundMarshaler, client, req, pathParams) 151 ctx = runtime.NewServerMetadataContext(ctx, md) 152 if err != nil { 153 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 154 return 155 } 156 157 forward_ChaincodePingerService_Ping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 158 159 }) 160 161 return nil 162 } 163 164 var ( 165 pattern_ChaincodePingerService_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"chaincode", "pinger", "ping"}, "", runtime.AssumeColonVerbOpt(true))) 166 ) 167 168 var ( 169 forward_ChaincodePingerService_Ping_0 = runtime.ForwardResponseMessage 170 )