...

Source file src/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generate_unbound_methods.pb.gw.go

Documentation: github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb

     1  // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
     2  // source: examples/internal/proto/examplepb/generate_unbound_methods.proto
     3  
     4  /*
     5  Package examplepb is a reverse proxy.
     6  
     7  It translates gRPC into RESTful JSON APIs.
     8  */
     9  package examplepb
    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_GenerateUnboundMethodsEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client GenerateUnboundMethodsEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    35  	var protoReq GenerateUnboundMethodsSimpleMessage
    36  	var metadata runtime.ServerMetadata
    37  
    38  	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
    39  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    40  	}
    41  
    42  	msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    43  	return msg, metadata, err
    44  
    45  }
    46  
    47  func local_request_GenerateUnboundMethodsEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server GenerateUnboundMethodsEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    48  	var protoReq GenerateUnboundMethodsSimpleMessage
    49  	var metadata runtime.ServerMetadata
    50  
    51  	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
    52  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    53  	}
    54  
    55  	msg, err := server.Echo(ctx, &protoReq)
    56  	return msg, metadata, err
    57  
    58  }
    59  
    60  func request_GenerateUnboundMethodsEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, client GenerateUnboundMethodsEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    61  	var protoReq GenerateUnboundMethodsSimpleMessage
    62  	var metadata runtime.ServerMetadata
    63  
    64  	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
    65  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    66  	}
    67  
    68  	msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    69  	return msg, metadata, err
    70  
    71  }
    72  
    73  func local_request_GenerateUnboundMethodsEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, server GenerateUnboundMethodsEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    74  	var protoReq GenerateUnboundMethodsSimpleMessage
    75  	var metadata runtime.ServerMetadata
    76  
    77  	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
    78  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    79  	}
    80  
    81  	msg, err := server.EchoBody(ctx, &protoReq)
    82  	return msg, metadata, err
    83  
    84  }
    85  
    86  func request_GenerateUnboundMethodsEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, client GenerateUnboundMethodsEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    87  	var protoReq GenerateUnboundMethodsSimpleMessage
    88  	var metadata runtime.ServerMetadata
    89  
    90  	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
    91  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    92  	}
    93  
    94  	msg, err := client.EchoDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    95  	return msg, metadata, err
    96  
    97  }
    98  
    99  func local_request_GenerateUnboundMethodsEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, server GenerateUnboundMethodsEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
   100  	var protoReq GenerateUnboundMethodsSimpleMessage
   101  	var metadata runtime.ServerMetadata
   102  
   103  	if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
   104  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
   105  	}
   106  
   107  	msg, err := server.EchoDelete(ctx, &protoReq)
   108  	return msg, metadata, err
   109  
   110  }
   111  
   112  // RegisterGenerateUnboundMethodsEchoServiceHandlerServer registers the http handlers for service GenerateUnboundMethodsEchoService to "mux".
   113  // UnaryRPC     :call GenerateUnboundMethodsEchoServiceServer directly.
   114  // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
   115  // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGenerateUnboundMethodsEchoServiceHandlerFromEndpoint instead.
   116  func RegisterGenerateUnboundMethodsEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GenerateUnboundMethodsEchoServiceServer) error {
   117  
   118  	mux.Handle("POST", pattern_GenerateUnboundMethodsEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   119  		ctx, cancel := context.WithCancel(req.Context())
   120  		defer cancel()
   121  		var stream runtime.ServerTransportStream
   122  		ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
   123  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   124  		var err error
   125  		var annotatedContext context.Context
   126  		annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo"))
   127  		if err != nil {
   128  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   129  			return
   130  		}
   131  		resp, md, err := local_request_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams)
   132  		md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
   133  		annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
   134  		if err != nil {
   135  			runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
   136  			return
   137  		}
   138  
   139  		forward_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   140  
   141  	})
   142  
   143  	mux.Handle("POST", pattern_GenerateUnboundMethodsEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   144  		ctx, cancel := context.WithCancel(req.Context())
   145  		defer cancel()
   146  		var stream runtime.ServerTransportStream
   147  		ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
   148  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   149  		var err error
   150  		var annotatedContext context.Context
   151  		annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody"))
   152  		if err != nil {
   153  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   154  			return
   155  		}
   156  		resp, md, err := local_request_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, inboundMarshaler, server, req, pathParams)
   157  		md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
   158  		annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
   159  		if err != nil {
   160  			runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
   161  			return
   162  		}
   163  
   164  		forward_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   165  
   166  	})
   167  
   168  	mux.Handle("POST", pattern_GenerateUnboundMethodsEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   169  		ctx, cancel := context.WithCancel(req.Context())
   170  		defer cancel()
   171  		var stream runtime.ServerTransportStream
   172  		ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
   173  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   174  		var err error
   175  		var annotatedContext context.Context
   176  		annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete"))
   177  		if err != nil {
   178  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   179  			return
   180  		}
   181  		resp, md, err := local_request_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams)
   182  		md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
   183  		annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
   184  		if err != nil {
   185  			runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
   186  			return
   187  		}
   188  
   189  		forward_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   190  
   191  	})
   192  
   193  	return nil
   194  }
   195  
   196  // RegisterGenerateUnboundMethodsEchoServiceHandlerFromEndpoint is same as RegisterGenerateUnboundMethodsEchoServiceHandler but
   197  // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
   198  func RegisterGenerateUnboundMethodsEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
   199  	conn, err := grpc.DialContext(ctx, endpoint, opts...)
   200  	if err != nil {
   201  		return err
   202  	}
   203  	defer func() {
   204  		if err != nil {
   205  			if cerr := conn.Close(); cerr != nil {
   206  				grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
   207  			}
   208  			return
   209  		}
   210  		go func() {
   211  			<-ctx.Done()
   212  			if cerr := conn.Close(); cerr != nil {
   213  				grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
   214  			}
   215  		}()
   216  	}()
   217  
   218  	return RegisterGenerateUnboundMethodsEchoServiceHandler(ctx, mux, conn)
   219  }
   220  
   221  // RegisterGenerateUnboundMethodsEchoServiceHandler registers the http handlers for service GenerateUnboundMethodsEchoService to "mux".
   222  // The handlers forward requests to the grpc endpoint over "conn".
   223  func RegisterGenerateUnboundMethodsEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
   224  	return RegisterGenerateUnboundMethodsEchoServiceHandlerClient(ctx, mux, NewGenerateUnboundMethodsEchoServiceClient(conn))
   225  }
   226  
   227  // RegisterGenerateUnboundMethodsEchoServiceHandlerClient registers the http handlers for service GenerateUnboundMethodsEchoService
   228  // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GenerateUnboundMethodsEchoServiceClient".
   229  // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GenerateUnboundMethodsEchoServiceClient"
   230  // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
   231  // "GenerateUnboundMethodsEchoServiceClient" to call the correct interceptors.
   232  func RegisterGenerateUnboundMethodsEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GenerateUnboundMethodsEchoServiceClient) error {
   233  
   234  	mux.Handle("POST", pattern_GenerateUnboundMethodsEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   235  		ctx, cancel := context.WithCancel(req.Context())
   236  		defer cancel()
   237  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   238  		var err error
   239  		var annotatedContext context.Context
   240  		annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo"))
   241  		if err != nil {
   242  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   243  			return
   244  		}
   245  		resp, md, err := request_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
   246  		annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
   247  		if err != nil {
   248  			runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
   249  			return
   250  		}
   251  
   252  		forward_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   253  
   254  	})
   255  
   256  	mux.Handle("POST", pattern_GenerateUnboundMethodsEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   257  		ctx, cancel := context.WithCancel(req.Context())
   258  		defer cancel()
   259  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   260  		var err error
   261  		var annotatedContext context.Context
   262  		annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody"))
   263  		if err != nil {
   264  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   265  			return
   266  		}
   267  		resp, md, err := request_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, inboundMarshaler, client, req, pathParams)
   268  		annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
   269  		if err != nil {
   270  			runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
   271  			return
   272  		}
   273  
   274  		forward_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   275  
   276  	})
   277  
   278  	mux.Handle("POST", pattern_GenerateUnboundMethodsEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   279  		ctx, cancel := context.WithCancel(req.Context())
   280  		defer cancel()
   281  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   282  		var err error
   283  		var annotatedContext context.Context
   284  		annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete"))
   285  		if err != nil {
   286  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   287  			return
   288  		}
   289  		resp, md, err := request_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams)
   290  		annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
   291  		if err != nil {
   292  			runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
   293  			return
   294  		}
   295  
   296  		forward_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   297  
   298  	})
   299  
   300  	return nil
   301  }
   302  
   303  var (
   304  	pattern_GenerateUnboundMethodsEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", "Echo"}, ""))
   305  
   306  	pattern_GenerateUnboundMethodsEchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", "EchoBody"}, ""))
   307  
   308  	pattern_GenerateUnboundMethodsEchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", "EchoDelete"}, ""))
   309  )
   310  
   311  var (
   312  	forward_GenerateUnboundMethodsEchoService_Echo_0 = runtime.ForwardResponseMessage
   313  
   314  	forward_GenerateUnboundMethodsEchoService_EchoBody_0 = runtime.ForwardResponseMessage
   315  
   316  	forward_GenerateUnboundMethodsEchoService_EchoDelete_0 = runtime.ForwardResponseMessage
   317  )
   318  

View as plain text