github.com/Finschia/finschia-sdk@v0.48.1/types/tx2/service.pb.gw.go (about)

     1  // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
     2  // source: lbm/tx/v1beta1/service.proto
     3  
     4  /*
     5  Package tx2 is a reverse proxy.
     6  
     7  It translates gRPC into RESTful JSON APIs.
     8  */
     9  package tx2
    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/status"
    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 _ = descriptor.ForMessage
    33  
    34  var (
    35  	filter_Service_GetBlockWithTxs_0 = &utilities.DoubleArray{Encoding: map[string]int{"height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
    36  )
    37  
    38  func request_Service_GetBlockWithTxs_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    39  	var protoReq GetBlockWithTxsRequest
    40  	var metadata runtime.ServerMetadata
    41  
    42  	var (
    43  		val string
    44  		ok  bool
    45  		err error
    46  		_   = err
    47  	)
    48  
    49  	val, ok = pathParams["height"]
    50  	if !ok {
    51  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height")
    52  	}
    53  
    54  	protoReq.Height, err = runtime.Int64(val)
    55  
    56  	if err != nil {
    57  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err)
    58  	}
    59  
    60  	if err := req.ParseForm(); err != nil {
    61  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    62  	}
    63  	if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_GetBlockWithTxs_0); err != nil {
    64  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    65  	}
    66  
    67  	msg, err := client.GetBlockWithTxs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    68  	return msg, metadata, err
    69  
    70  }
    71  
    72  func local_request_Service_GetBlockWithTxs_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    73  	var protoReq GetBlockWithTxsRequest
    74  	var metadata runtime.ServerMetadata
    75  
    76  	var (
    77  		val string
    78  		ok  bool
    79  		err error
    80  		_   = err
    81  	)
    82  
    83  	val, ok = pathParams["height"]
    84  	if !ok {
    85  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height")
    86  	}
    87  
    88  	protoReq.Height, err = runtime.Int64(val)
    89  
    90  	if err != nil {
    91  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err)
    92  	}
    93  
    94  	if err := req.ParseForm(); err != nil {
    95  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    96  	}
    97  	if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_GetBlockWithTxs_0); err != nil {
    98  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    99  	}
   100  
   101  	msg, err := server.GetBlockWithTxs(ctx, &protoReq)
   102  	return msg, metadata, err
   103  
   104  }
   105  
   106  // RegisterServiceHandlerServer registers the http handlers for service Service to "mux".
   107  // UnaryRPC     :call ServiceServer directly.
   108  // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
   109  // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterServiceHandlerFromEndpoint instead.
   110  func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceServer) error {
   111  
   112  	mux.Handle("GET", pattern_Service_GetBlockWithTxs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   113  		ctx, cancel := context.WithCancel(req.Context())
   114  		defer cancel()
   115  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   116  		rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
   117  		if err != nil {
   118  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   119  			return
   120  		}
   121  		resp, md, err := local_request_Service_GetBlockWithTxs_0(rctx, inboundMarshaler, server, req, pathParams)
   122  		ctx = runtime.NewServerMetadataContext(ctx, md)
   123  		if err != nil {
   124  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   125  			return
   126  		}
   127  
   128  		forward_Service_GetBlockWithTxs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   129  
   130  	})
   131  
   132  	return nil
   133  }
   134  
   135  // RegisterServiceHandlerFromEndpoint is same as RegisterServiceHandler but
   136  // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
   137  func RegisterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
   138  	conn, err := grpc.Dial(endpoint, opts...)
   139  	if err != nil {
   140  		return err
   141  	}
   142  	defer func() {
   143  		if err != nil {
   144  			if cerr := conn.Close(); cerr != nil {
   145  				grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
   146  			}
   147  			return
   148  		}
   149  		go func() {
   150  			<-ctx.Done()
   151  			if cerr := conn.Close(); cerr != nil {
   152  				grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
   153  			}
   154  		}()
   155  	}()
   156  
   157  	return RegisterServiceHandler(ctx, mux, conn)
   158  }
   159  
   160  // RegisterServiceHandler registers the http handlers for service Service to "mux".
   161  // The handlers forward requests to the grpc endpoint over "conn".
   162  func RegisterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
   163  	return RegisterServiceHandlerClient(ctx, mux, NewServiceClient(conn))
   164  }
   165  
   166  // RegisterServiceHandlerClient registers the http handlers for service Service
   167  // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceClient".
   168  // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceClient"
   169  // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
   170  // "ServiceClient" to call the correct interceptors.
   171  func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceClient) error {
   172  
   173  	mux.Handle("GET", pattern_Service_GetBlockWithTxs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   174  		ctx, cancel := context.WithCancel(req.Context())
   175  		defer cancel()
   176  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   177  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   178  		if err != nil {
   179  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   180  			return
   181  		}
   182  		resp, md, err := request_Service_GetBlockWithTxs_0(rctx, inboundMarshaler, client, req, pathParams)
   183  		ctx = runtime.NewServerMetadataContext(ctx, md)
   184  		if err != nil {
   185  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   186  			return
   187  		}
   188  
   189  		forward_Service_GetBlockWithTxs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   190  
   191  	})
   192  
   193  	return nil
   194  }
   195  
   196  var (
   197  	pattern_Service_GetBlockWithTxs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"lbm", "tx", "v1beta1", "txs", "block", "height"}, "", runtime.AssumeColonVerbOpt(false)))
   198  )
   199  
   200  var (
   201  	forward_Service_GetBlockWithTxs_0 = runtime.ForwardResponseMessage
   202  )