github.com/decred/dcrlnd@v0.7.6/lnrpc/initchainsyncrpc/initchainsync.pb.gw.go (about) 1 // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. 2 // source: initchainsyncrpc/initchainsync.proto 3 4 /* 5 Package initchainsyncrpc is a reverse proxy. 6 7 It translates gRPC into RESTful JSON APIs. 8 */ 9 package initchainsyncrpc 10 11 import ( 12 "context" 13 "io" 14 "net/http" 15 16 "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" 17 "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" 18 "google.golang.org/grpc" 19 "google.golang.org/grpc/codes" 20 "google.golang.org/grpc/grpclog" 21 "google.golang.org/grpc/metadata" 22 "google.golang.org/grpc/status" 23 "google.golang.org/protobuf/proto" 24 ) 25 26 // Suppress "imported and not used" errors 27 var _ codes.Code 28 var _ io.Reader 29 var _ status.Status 30 var _ = runtime.String 31 var _ = utilities.NewDoubleArray 32 var _ = metadata.Join 33 34 func request_InitialChainSync_SubscribeChainSync_0(ctx context.Context, marshaler runtime.Marshaler, client InitialChainSyncClient, req *http.Request, pathParams map[string]string) (InitialChainSync_SubscribeChainSyncClient, runtime.ServerMetadata, error) { 35 var protoReq ChainSyncSubscription 36 var metadata runtime.ServerMetadata 37 38 stream, err := client.SubscribeChainSync(ctx, &protoReq) 39 if err != nil { 40 return nil, metadata, err 41 } 42 header, err := stream.Header() 43 if err != nil { 44 return nil, metadata, err 45 } 46 metadata.HeaderMD = header 47 return stream, metadata, nil 48 49 } 50 51 // RegisterInitialChainSyncHandlerServer registers the http handlers for service InitialChainSync to "mux". 52 // UnaryRPC :call InitialChainSyncServer directly. 53 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 54 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterInitialChainSyncHandlerFromEndpoint instead. 55 func RegisterInitialChainSyncHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InitialChainSyncServer) error { 56 57 mux.Handle("GET", pattern_InitialChainSync_SubscribeChainSync_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 58 err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") 59 _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 60 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 61 return 62 }) 63 64 return nil 65 } 66 67 // RegisterInitialChainSyncHandlerFromEndpoint is same as RegisterInitialChainSyncHandler but 68 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 69 func RegisterInitialChainSyncHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 70 conn, err := grpc.Dial(endpoint, opts...) 71 if err != nil { 72 return err 73 } 74 defer func() { 75 if err != nil { 76 if cerr := conn.Close(); cerr != nil { 77 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 78 } 79 return 80 } 81 go func() { 82 <-ctx.Done() 83 if cerr := conn.Close(); cerr != nil { 84 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 85 } 86 }() 87 }() 88 89 return RegisterInitialChainSyncHandler(ctx, mux, conn) 90 } 91 92 // RegisterInitialChainSyncHandler registers the http handlers for service InitialChainSync to "mux". 93 // The handlers forward requests to the grpc endpoint over "conn". 94 func RegisterInitialChainSyncHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 95 return RegisterInitialChainSyncHandlerClient(ctx, mux, NewInitialChainSyncClient(conn)) 96 } 97 98 // RegisterInitialChainSyncHandlerClient registers the http handlers for service InitialChainSync 99 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InitialChainSyncClient". 100 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InitialChainSyncClient" 101 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 102 // "InitialChainSyncClient" to call the correct interceptors. 103 func RegisterInitialChainSyncHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InitialChainSyncClient) error { 104 105 mux.Handle("GET", pattern_InitialChainSync_SubscribeChainSync_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 106 ctx, cancel := context.WithCancel(req.Context()) 107 defer cancel() 108 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 109 rctx, err := runtime.AnnotateContext(ctx, mux, req, "/initialchainsyncrpc.InitialChainSync/SubscribeChainSync", runtime.WithHTTPPathPattern("/v2/initchainsync/subscribe")) 110 if err != nil { 111 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 112 return 113 } 114 resp, md, err := request_InitialChainSync_SubscribeChainSync_0(rctx, inboundMarshaler, client, req, pathParams) 115 ctx = runtime.NewServerMetadataContext(ctx, md) 116 if err != nil { 117 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 118 return 119 } 120 121 forward_InitialChainSync_SubscribeChainSync_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) 122 123 }) 124 125 return nil 126 } 127 128 var ( 129 pattern_InitialChainSync_SubscribeChainSync_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "initchainsync", "subscribe"}, "")) 130 ) 131 132 var ( 133 forward_InitialChainSync_SubscribeChainSync_0 = runtime.ForwardResponseStream 134 )