github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/examples/internal/proto/examplepb/visibility_rule_echo_service.pb.gw.go (about) 1 // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. 2 // source: examples/internal/proto/examplepb/visibility_rule_echo_service.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 var ( 35 filter_VisibilityRuleEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} 36 ) 37 38 func request_VisibilityRuleEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 39 var protoReq VisibilityRuleSimpleMessage 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["id"] 50 if !ok { 51 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") 52 } 53 54 protoReq.Id, err = runtime.String(val) 55 if err != nil { 56 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) 57 } 58 59 if err := req.ParseForm(); err != nil { 60 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 61 } 62 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_Echo_0); err != nil { 63 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 64 } 65 66 msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 67 return msg, metadata, err 68 69 } 70 71 func local_request_VisibilityRuleEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 72 var protoReq VisibilityRuleSimpleMessage 73 var metadata runtime.ServerMetadata 74 75 var ( 76 val string 77 ok bool 78 err error 79 _ = err 80 ) 81 82 val, ok = pathParams["id"] 83 if !ok { 84 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") 85 } 86 87 protoReq.Id, err = runtime.String(val) 88 if err != nil { 89 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) 90 } 91 92 if err := req.ParseForm(); err != nil { 93 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 94 } 95 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_Echo_0); err != nil { 96 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 97 } 98 99 msg, err := server.Echo(ctx, &protoReq) 100 return msg, metadata, err 101 102 } 103 104 var ( 105 filter_VisibilityRuleEchoService_EchoInternal_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} 106 ) 107 108 func request_VisibilityRuleEchoService_EchoInternal_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 109 var protoReq VisibilityRuleSimpleMessage 110 var metadata runtime.ServerMetadata 111 112 if err := req.ParseForm(); err != nil { 113 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 114 } 115 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternal_0); err != nil { 116 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 117 } 118 119 msg, err := client.EchoInternal(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 120 return msg, metadata, err 121 122 } 123 124 func local_request_VisibilityRuleEchoService_EchoInternal_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 125 var protoReq VisibilityRuleSimpleMessage 126 var metadata runtime.ServerMetadata 127 128 if err := req.ParseForm(); err != nil { 129 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 130 } 131 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternal_0); err != nil { 132 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 133 } 134 135 msg, err := server.EchoInternal(ctx, &protoReq) 136 return msg, metadata, err 137 138 } 139 140 var ( 141 filter_VisibilityRuleEchoService_EchoPreview_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} 142 ) 143 144 func request_VisibilityRuleEchoService_EchoPreview_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 145 var protoReq VisibilityRuleSimpleMessage 146 var metadata runtime.ServerMetadata 147 148 if err := req.ParseForm(); err != nil { 149 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 150 } 151 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoPreview_0); err != nil { 152 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 153 } 154 155 msg, err := client.EchoPreview(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 156 return msg, metadata, err 157 158 } 159 160 func local_request_VisibilityRuleEchoService_EchoPreview_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 161 var protoReq VisibilityRuleSimpleMessage 162 var metadata runtime.ServerMetadata 163 164 if err := req.ParseForm(); err != nil { 165 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 166 } 167 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoPreview_0); err != nil { 168 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 169 } 170 171 msg, err := server.EchoPreview(ctx, &protoReq) 172 return msg, metadata, err 173 174 } 175 176 var ( 177 filter_VisibilityRuleEchoService_EchoInternalAndPreview_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} 178 ) 179 180 func request_VisibilityRuleEchoService_EchoInternalAndPreview_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 181 var protoReq VisibilityRuleSimpleMessage 182 var metadata runtime.ServerMetadata 183 184 if err := req.ParseForm(); err != nil { 185 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 186 } 187 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternalAndPreview_0); err != nil { 188 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 189 } 190 191 msg, err := client.EchoInternalAndPreview(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 192 return msg, metadata, err 193 194 } 195 196 func local_request_VisibilityRuleEchoService_EchoInternalAndPreview_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 197 var protoReq VisibilityRuleSimpleMessage 198 var metadata runtime.ServerMetadata 199 200 if err := req.ParseForm(); err != nil { 201 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 202 } 203 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternalAndPreview_0); err != nil { 204 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 205 } 206 207 msg, err := server.EchoInternalAndPreview(ctx, &protoReq) 208 return msg, metadata, err 209 210 } 211 212 var ( 213 filter_VisibilityRuleInternalEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} 214 ) 215 216 func request_VisibilityRuleInternalEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleInternalEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 217 var protoReq VisibilityRuleSimpleMessage 218 var metadata runtime.ServerMetadata 219 220 var ( 221 val string 222 ok bool 223 err error 224 _ = err 225 ) 226 227 val, ok = pathParams["id"] 228 if !ok { 229 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") 230 } 231 232 protoReq.Id, err = runtime.String(val) 233 if err != nil { 234 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) 235 } 236 237 if err := req.ParseForm(); err != nil { 238 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 239 } 240 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleInternalEchoService_Echo_0); err != nil { 241 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 242 } 243 244 msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 245 return msg, metadata, err 246 247 } 248 249 func local_request_VisibilityRuleInternalEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleInternalEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 250 var protoReq VisibilityRuleSimpleMessage 251 var metadata runtime.ServerMetadata 252 253 var ( 254 val string 255 ok bool 256 err error 257 _ = err 258 ) 259 260 val, ok = pathParams["id"] 261 if !ok { 262 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") 263 } 264 265 protoReq.Id, err = runtime.String(val) 266 if err != nil { 267 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) 268 } 269 270 if err := req.ParseForm(); err != nil { 271 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 272 } 273 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleInternalEchoService_Echo_0); err != nil { 274 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 275 } 276 277 msg, err := server.Echo(ctx, &protoReq) 278 return msg, metadata, err 279 280 } 281 282 // RegisterVisibilityRuleEchoServiceHandlerServer registers the http handlers for service VisibilityRuleEchoService to "mux". 283 // UnaryRPC :call VisibilityRuleEchoServiceServer directly. 284 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 285 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterVisibilityRuleEchoServiceHandlerFromEndpoint instead. 286 func RegisterVisibilityRuleEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server VisibilityRuleEchoServiceServer) error { 287 288 mux.Handle("POST", pattern_VisibilityRuleEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 289 ctx, cancel := context.WithCancel(req.Context()) 290 defer cancel() 291 var stream runtime.ServerTransportStream 292 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 293 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 294 var err error 295 var annotatedContext context.Context 296 annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) 297 if err != nil { 298 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 299 return 300 } 301 resp, md, err := local_request_VisibilityRuleEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) 302 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 303 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 304 if err != nil { 305 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 306 return 307 } 308 309 forward_VisibilityRuleEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 310 311 }) 312 313 mux.Handle("GET", pattern_VisibilityRuleEchoService_EchoInternal_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 314 ctx, cancel := context.WithCancel(req.Context()) 315 defer cancel() 316 var stream runtime.ServerTransportStream 317 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 318 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 319 var err error 320 var annotatedContext context.Context 321 annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternal", runtime.WithHTTPPathPattern("/v1/example/echo_internal")) 322 if err != nil { 323 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 324 return 325 } 326 resp, md, err := local_request_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, inboundMarshaler, server, req, pathParams) 327 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 328 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 329 if err != nil { 330 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 331 return 332 } 333 334 forward_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 335 336 }) 337 338 mux.Handle("GET", pattern_VisibilityRuleEchoService_EchoPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 339 ctx, cancel := context.WithCancel(req.Context()) 340 defer cancel() 341 var stream runtime.ServerTransportStream 342 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 343 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 344 var err error 345 var annotatedContext context.Context 346 annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoPreview", runtime.WithHTTPPathPattern("/v1/example/echo_preview")) 347 if err != nil { 348 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 349 return 350 } 351 resp, md, err := local_request_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, inboundMarshaler, server, req, pathParams) 352 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 353 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 354 if err != nil { 355 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 356 return 357 } 358 359 forward_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 360 361 }) 362 363 mux.Handle("GET", pattern_VisibilityRuleEchoService_EchoInternalAndPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 364 ctx, cancel := context.WithCancel(req.Context()) 365 defer cancel() 366 var stream runtime.ServerTransportStream 367 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 368 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 369 var err error 370 var annotatedContext context.Context 371 annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternalAndPreview", runtime.WithHTTPPathPattern("/v1/example/echo_internal_and_preview")) 372 if err != nil { 373 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 374 return 375 } 376 resp, md, err := local_request_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, inboundMarshaler, server, req, pathParams) 377 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 378 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 379 if err != nil { 380 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 381 return 382 } 383 384 forward_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 385 386 }) 387 388 return nil 389 } 390 391 // RegisterVisibilityRuleInternalEchoServiceHandlerServer registers the http handlers for service VisibilityRuleInternalEchoService to "mux". 392 // UnaryRPC :call VisibilityRuleInternalEchoServiceServer directly. 393 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 394 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterVisibilityRuleInternalEchoServiceHandlerFromEndpoint instead. 395 func RegisterVisibilityRuleInternalEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server VisibilityRuleInternalEchoServiceServer) error { 396 397 mux.Handle("POST", pattern_VisibilityRuleInternalEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 398 ctx, cancel := context.WithCancel(req.Context()) 399 defer cancel() 400 var stream runtime.ServerTransportStream 401 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 402 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 403 var err error 404 var annotatedContext context.Context 405 annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/internal/echo/{id}")) 406 if err != nil { 407 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 408 return 409 } 410 resp, md, err := local_request_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) 411 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 412 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 413 if err != nil { 414 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 415 return 416 } 417 418 forward_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 419 420 }) 421 422 return nil 423 } 424 425 // RegisterVisibilityRuleEchoServiceHandlerFromEndpoint is same as RegisterVisibilityRuleEchoServiceHandler but 426 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 427 func RegisterVisibilityRuleEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 428 conn, err := grpc.DialContext(ctx, endpoint, opts...) 429 if err != nil { 430 return err 431 } 432 defer func() { 433 if err != nil { 434 if cerr := conn.Close(); cerr != nil { 435 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 436 } 437 return 438 } 439 go func() { 440 <-ctx.Done() 441 if cerr := conn.Close(); cerr != nil { 442 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 443 } 444 }() 445 }() 446 447 return RegisterVisibilityRuleEchoServiceHandler(ctx, mux, conn) 448 } 449 450 // RegisterVisibilityRuleEchoServiceHandler registers the http handlers for service VisibilityRuleEchoService to "mux". 451 // The handlers forward requests to the grpc endpoint over "conn". 452 func RegisterVisibilityRuleEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 453 return RegisterVisibilityRuleEchoServiceHandlerClient(ctx, mux, NewVisibilityRuleEchoServiceClient(conn)) 454 } 455 456 // RegisterVisibilityRuleEchoServiceHandlerClient registers the http handlers for service VisibilityRuleEchoService 457 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "VisibilityRuleEchoServiceClient". 458 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "VisibilityRuleEchoServiceClient" 459 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 460 // "VisibilityRuleEchoServiceClient" to call the correct interceptors. 461 func RegisterVisibilityRuleEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client VisibilityRuleEchoServiceClient) error { 462 463 mux.Handle("POST", pattern_VisibilityRuleEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 464 ctx, cancel := context.WithCancel(req.Context()) 465 defer cancel() 466 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 467 var err error 468 var annotatedContext context.Context 469 annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) 470 if err != nil { 471 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 472 return 473 } 474 resp, md, err := request_VisibilityRuleEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) 475 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 476 if err != nil { 477 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 478 return 479 } 480 481 forward_VisibilityRuleEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 482 483 }) 484 485 mux.Handle("GET", pattern_VisibilityRuleEchoService_EchoInternal_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 486 ctx, cancel := context.WithCancel(req.Context()) 487 defer cancel() 488 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 489 var err error 490 var annotatedContext context.Context 491 annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternal", runtime.WithHTTPPathPattern("/v1/example/echo_internal")) 492 if err != nil { 493 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 494 return 495 } 496 resp, md, err := request_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, inboundMarshaler, client, req, pathParams) 497 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 498 if err != nil { 499 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 500 return 501 } 502 503 forward_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 504 505 }) 506 507 mux.Handle("GET", pattern_VisibilityRuleEchoService_EchoPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 508 ctx, cancel := context.WithCancel(req.Context()) 509 defer cancel() 510 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 511 var err error 512 var annotatedContext context.Context 513 annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoPreview", runtime.WithHTTPPathPattern("/v1/example/echo_preview")) 514 if err != nil { 515 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 516 return 517 } 518 resp, md, err := request_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, inboundMarshaler, client, req, pathParams) 519 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 520 if err != nil { 521 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 522 return 523 } 524 525 forward_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 526 527 }) 528 529 mux.Handle("GET", pattern_VisibilityRuleEchoService_EchoInternalAndPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 530 ctx, cancel := context.WithCancel(req.Context()) 531 defer cancel() 532 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 533 var err error 534 var annotatedContext context.Context 535 annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternalAndPreview", runtime.WithHTTPPathPattern("/v1/example/echo_internal_and_preview")) 536 if err != nil { 537 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 538 return 539 } 540 resp, md, err := request_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, inboundMarshaler, client, req, pathParams) 541 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 542 if err != nil { 543 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 544 return 545 } 546 547 forward_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 548 549 }) 550 551 return nil 552 } 553 554 var ( 555 pattern_VisibilityRuleEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo", "id"}, "")) 556 557 pattern_VisibilityRuleEchoService_EchoInternal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_internal"}, "")) 558 559 pattern_VisibilityRuleEchoService_EchoPreview_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_preview"}, "")) 560 561 pattern_VisibilityRuleEchoService_EchoInternalAndPreview_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_internal_and_preview"}, "")) 562 ) 563 564 var ( 565 forward_VisibilityRuleEchoService_Echo_0 = runtime.ForwardResponseMessage 566 567 forward_VisibilityRuleEchoService_EchoInternal_0 = runtime.ForwardResponseMessage 568 569 forward_VisibilityRuleEchoService_EchoPreview_0 = runtime.ForwardResponseMessage 570 571 forward_VisibilityRuleEchoService_EchoInternalAndPreview_0 = runtime.ForwardResponseMessage 572 ) 573 574 // RegisterVisibilityRuleInternalEchoServiceHandlerFromEndpoint is same as RegisterVisibilityRuleInternalEchoServiceHandler but 575 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 576 func RegisterVisibilityRuleInternalEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 577 conn, err := grpc.DialContext(ctx, endpoint, opts...) 578 if err != nil { 579 return err 580 } 581 defer func() { 582 if err != nil { 583 if cerr := conn.Close(); cerr != nil { 584 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 585 } 586 return 587 } 588 go func() { 589 <-ctx.Done() 590 if cerr := conn.Close(); cerr != nil { 591 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 592 } 593 }() 594 }() 595 596 return RegisterVisibilityRuleInternalEchoServiceHandler(ctx, mux, conn) 597 } 598 599 // RegisterVisibilityRuleInternalEchoServiceHandler registers the http handlers for service VisibilityRuleInternalEchoService to "mux". 600 // The handlers forward requests to the grpc endpoint over "conn". 601 func RegisterVisibilityRuleInternalEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 602 return RegisterVisibilityRuleInternalEchoServiceHandlerClient(ctx, mux, NewVisibilityRuleInternalEchoServiceClient(conn)) 603 } 604 605 // RegisterVisibilityRuleInternalEchoServiceHandlerClient registers the http handlers for service VisibilityRuleInternalEchoService 606 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "VisibilityRuleInternalEchoServiceClient". 607 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "VisibilityRuleInternalEchoServiceClient" 608 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 609 // "VisibilityRuleInternalEchoServiceClient" to call the correct interceptors. 610 func RegisterVisibilityRuleInternalEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client VisibilityRuleInternalEchoServiceClient) error { 611 612 mux.Handle("POST", pattern_VisibilityRuleInternalEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 613 ctx, cancel := context.WithCancel(req.Context()) 614 defer cancel() 615 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 616 var err error 617 var annotatedContext context.Context 618 annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/internal/echo/{id}")) 619 if err != nil { 620 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 621 return 622 } 623 resp, md, err := request_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) 624 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 625 if err != nil { 626 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 627 return 628 } 629 630 forward_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 631 632 }) 633 634 return nil 635 } 636 637 var ( 638 pattern_VisibilityRuleInternalEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "internal", "echo", "id"}, "")) 639 ) 640 641 var ( 642 forward_VisibilityRuleInternalEchoService_Echo_0 = runtime.ForwardResponseMessage 643 )