github.com/s7techlab/cckit@v0.10.5/examples/token/service/account/account.pb.gw.go (about)

     1  // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
     2  // source: token/service/account/account.proto
     3  
     4  /*
     5  Package account is a reverse proxy.
     6  
     7  It translates gRPC into RESTful JSON APIs.
     8  */
     9  package account
    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_AccountService_GetInvokerAddress_0(ctx context.Context, marshaler runtime.Marshaler, client AccountServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    38  	var protoReq emptypb.Empty
    39  	var metadata runtime.ServerMetadata
    40  
    41  	msg, err := client.GetInvokerAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    42  	return msg, metadata, err
    43  
    44  }
    45  
    46  func local_request_AccountService_GetInvokerAddress_0(ctx context.Context, marshaler runtime.Marshaler, server AccountServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    47  	var protoReq emptypb.Empty
    48  	var metadata runtime.ServerMetadata
    49  
    50  	msg, err := server.GetInvokerAddress(ctx, &protoReq)
    51  	return msg, metadata, err
    52  
    53  }
    54  
    55  func request_AccountService_GetAddress_0(ctx context.Context, marshaler runtime.Marshaler, client AccountServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    56  	var protoReq GetAddressRequest
    57  	var metadata runtime.ServerMetadata
    58  
    59  	var (
    60  		val string
    61  		ok  bool
    62  		err error
    63  		_   = err
    64  	)
    65  
    66  	val, ok = pathParams["public_key"]
    67  	if !ok {
    68  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "public_key")
    69  	}
    70  
    71  	protoReq.PublicKey, err = runtime.Bytes(val)
    72  
    73  	if err != nil {
    74  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "public_key", err)
    75  	}
    76  
    77  	msg, err := client.GetAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    78  	return msg, metadata, err
    79  
    80  }
    81  
    82  func local_request_AccountService_GetAddress_0(ctx context.Context, marshaler runtime.Marshaler, server AccountServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    83  	var protoReq GetAddressRequest
    84  	var metadata runtime.ServerMetadata
    85  
    86  	var (
    87  		val string
    88  		ok  bool
    89  		err error
    90  		_   = err
    91  	)
    92  
    93  	val, ok = pathParams["public_key"]
    94  	if !ok {
    95  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "public_key")
    96  	}
    97  
    98  	protoReq.PublicKey, err = runtime.Bytes(val)
    99  
   100  	if err != nil {
   101  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "public_key", err)
   102  	}
   103  
   104  	msg, err := server.GetAddress(ctx, &protoReq)
   105  	return msg, metadata, err
   106  
   107  }
   108  
   109  func request_AccountService_GetAccount_0(ctx context.Context, marshaler runtime.Marshaler, client AccountServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
   110  	var protoReq AccountId
   111  	var metadata runtime.ServerMetadata
   112  
   113  	var (
   114  		val string
   115  		ok  bool
   116  		err error
   117  		_   = err
   118  	)
   119  
   120  	val, ok = pathParams["address"]
   121  	if !ok {
   122  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
   123  	}
   124  
   125  	protoReq.Address, err = runtime.String(val)
   126  
   127  	if err != nil {
   128  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
   129  	}
   130  
   131  	msg, err := client.GetAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
   132  	return msg, metadata, err
   133  
   134  }
   135  
   136  func local_request_AccountService_GetAccount_0(ctx context.Context, marshaler runtime.Marshaler, server AccountServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
   137  	var protoReq AccountId
   138  	var metadata runtime.ServerMetadata
   139  
   140  	var (
   141  		val string
   142  		ok  bool
   143  		err error
   144  		_   = err
   145  	)
   146  
   147  	val, ok = pathParams["address"]
   148  	if !ok {
   149  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address")
   150  	}
   151  
   152  	protoReq.Address, err = runtime.String(val)
   153  
   154  	if err != nil {
   155  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err)
   156  	}
   157  
   158  	msg, err := server.GetAccount(ctx, &protoReq)
   159  	return msg, metadata, err
   160  
   161  }
   162  
   163  // RegisterAccountServiceHandlerServer registers the http handlers for service AccountService to "mux".
   164  // UnaryRPC     :call AccountServiceServer directly.
   165  // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
   166  // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAccountServiceHandlerFromEndpoint instead.
   167  func RegisterAccountServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AccountServiceServer) error {
   168  
   169  	mux.Handle("GET", pattern_AccountService_GetInvokerAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   170  		ctx, cancel := context.WithCancel(req.Context())
   171  		defer cancel()
   172  		var stream runtime.ServerTransportStream
   173  		ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
   174  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   175  		rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
   176  		if err != nil {
   177  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   178  			return
   179  		}
   180  		resp, md, err := local_request_AccountService_GetInvokerAddress_0(rctx, inboundMarshaler, server, req, pathParams)
   181  		md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
   182  		ctx = runtime.NewServerMetadataContext(ctx, md)
   183  		if err != nil {
   184  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   185  			return
   186  		}
   187  
   188  		forward_AccountService_GetInvokerAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   189  
   190  	})
   191  
   192  	mux.Handle("GET", pattern_AccountService_GetAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   193  		ctx, cancel := context.WithCancel(req.Context())
   194  		defer cancel()
   195  		var stream runtime.ServerTransportStream
   196  		ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
   197  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   198  		rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
   199  		if err != nil {
   200  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   201  			return
   202  		}
   203  		resp, md, err := local_request_AccountService_GetAddress_0(rctx, inboundMarshaler, server, req, pathParams)
   204  		md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
   205  		ctx = runtime.NewServerMetadataContext(ctx, md)
   206  		if err != nil {
   207  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   208  			return
   209  		}
   210  
   211  		forward_AccountService_GetAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   212  
   213  	})
   214  
   215  	mux.Handle("GET", pattern_AccountService_GetAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   216  		ctx, cancel := context.WithCancel(req.Context())
   217  		defer cancel()
   218  		var stream runtime.ServerTransportStream
   219  		ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
   220  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   221  		rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
   222  		if err != nil {
   223  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   224  			return
   225  		}
   226  		resp, md, err := local_request_AccountService_GetAccount_0(rctx, inboundMarshaler, server, req, pathParams)
   227  		md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
   228  		ctx = runtime.NewServerMetadataContext(ctx, md)
   229  		if err != nil {
   230  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   231  			return
   232  		}
   233  
   234  		forward_AccountService_GetAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   235  
   236  	})
   237  
   238  	return nil
   239  }
   240  
   241  // RegisterAccountServiceHandlerFromEndpoint is same as RegisterAccountServiceHandler but
   242  // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
   243  func RegisterAccountServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
   244  	conn, err := grpc.Dial(endpoint, opts...)
   245  	if err != nil {
   246  		return err
   247  	}
   248  	defer func() {
   249  		if err != nil {
   250  			if cerr := conn.Close(); cerr != nil {
   251  				grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
   252  			}
   253  			return
   254  		}
   255  		go func() {
   256  			<-ctx.Done()
   257  			if cerr := conn.Close(); cerr != nil {
   258  				grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
   259  			}
   260  		}()
   261  	}()
   262  
   263  	return RegisterAccountServiceHandler(ctx, mux, conn)
   264  }
   265  
   266  // RegisterAccountServiceHandler registers the http handlers for service AccountService to "mux".
   267  // The handlers forward requests to the grpc endpoint over "conn".
   268  func RegisterAccountServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
   269  	return RegisterAccountServiceHandlerClient(ctx, mux, NewAccountServiceClient(conn))
   270  }
   271  
   272  // RegisterAccountServiceHandlerClient registers the http handlers for service AccountService
   273  // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AccountServiceClient".
   274  // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AccountServiceClient"
   275  // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
   276  // "AccountServiceClient" to call the correct interceptors.
   277  func RegisterAccountServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AccountServiceClient) error {
   278  
   279  	mux.Handle("GET", pattern_AccountService_GetInvokerAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   280  		ctx, cancel := context.WithCancel(req.Context())
   281  		defer cancel()
   282  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   283  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   284  		if err != nil {
   285  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   286  			return
   287  		}
   288  		resp, md, err := request_AccountService_GetInvokerAddress_0(rctx, inboundMarshaler, client, req, pathParams)
   289  		ctx = runtime.NewServerMetadataContext(ctx, md)
   290  		if err != nil {
   291  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   292  			return
   293  		}
   294  
   295  		forward_AccountService_GetInvokerAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   296  
   297  	})
   298  
   299  	mux.Handle("GET", pattern_AccountService_GetAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   300  		ctx, cancel := context.WithCancel(req.Context())
   301  		defer cancel()
   302  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   303  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   304  		if err != nil {
   305  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   306  			return
   307  		}
   308  		resp, md, err := request_AccountService_GetAddress_0(rctx, inboundMarshaler, client, req, pathParams)
   309  		ctx = runtime.NewServerMetadataContext(ctx, md)
   310  		if err != nil {
   311  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   312  			return
   313  		}
   314  
   315  		forward_AccountService_GetAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   316  
   317  	})
   318  
   319  	mux.Handle("GET", pattern_AccountService_GetAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   320  		ctx, cancel := context.WithCancel(req.Context())
   321  		defer cancel()
   322  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   323  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   324  		if err != nil {
   325  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   326  			return
   327  		}
   328  		resp, md, err := request_AccountService_GetAccount_0(rctx, inboundMarshaler, client, req, pathParams)
   329  		ctx = runtime.NewServerMetadataContext(ctx, md)
   330  		if err != nil {
   331  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   332  			return
   333  		}
   334  
   335  		forward_AccountService_GetAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   336  
   337  	})
   338  
   339  	return nil
   340  }
   341  
   342  var (
   343  	pattern_AccountService_GetInvokerAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"token", "addresses", "whoami"}, "", runtime.AssumeColonVerbOpt(true)))
   344  
   345  	pattern_AccountService_GetAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"token", "addresses", "public_key"}, "", runtime.AssumeColonVerbOpt(true)))
   346  
   347  	pattern_AccountService_GetAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"token", "accounts", "address"}, "", runtime.AssumeColonVerbOpt(true)))
   348  )
   349  
   350  var (
   351  	forward_AccountService_GetInvokerAddress_0 = runtime.ForwardResponseMessage
   352  
   353  	forward_AccountService_GetAddress_0 = runtime.ForwardResponseMessage
   354  
   355  	forward_AccountService_GetAccount_0 = runtime.ForwardResponseMessage
   356  )