agones.dev/agones@v1.53.0/pkg/allocation/go/allocation.pb.gw.go (about) 1 // Copyright 2024 Google LLC All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // This code was autogenerated. Do not edit directly. 16 // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. 17 // source: proto/allocation/allocation.proto 18 19 /* 20 Package allocation is a reverse proxy. 21 22 It translates gRPC into RESTful JSON APIs. 23 */ 24 package allocation 25 26 import ( 27 "context" 28 "errors" 29 "io" 30 "net/http" 31 32 "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" 33 "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" 34 "google.golang.org/grpc" 35 "google.golang.org/grpc/codes" 36 "google.golang.org/grpc/grpclog" 37 "google.golang.org/grpc/metadata" 38 "google.golang.org/grpc/status" 39 "google.golang.org/protobuf/proto" 40 ) 41 42 // Suppress "imported and not used" errors 43 var ( 44 _ codes.Code 45 _ io.Reader 46 _ status.Status 47 _ = errors.New 48 _ = runtime.String 49 _ = utilities.NewDoubleArray 50 _ = metadata.Join 51 ) 52 53 func request_AllocationService_Allocate_0(ctx context.Context, marshaler runtime.Marshaler, client AllocationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 54 var ( 55 protoReq AllocationRequest 56 metadata runtime.ServerMetadata 57 ) 58 if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { 59 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 60 } 61 msg, err := client.Allocate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 62 return msg, metadata, err 63 } 64 65 func local_request_AllocationService_Allocate_0(ctx context.Context, marshaler runtime.Marshaler, server AllocationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 66 var ( 67 protoReq AllocationRequest 68 metadata runtime.ServerMetadata 69 ) 70 if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { 71 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 72 } 73 msg, err := server.Allocate(ctx, &protoReq) 74 return msg, metadata, err 75 } 76 77 // RegisterAllocationServiceHandlerServer registers the http handlers for service AllocationService to "mux". 78 // UnaryRPC :call AllocationServiceServer directly. 79 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 80 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAllocationServiceHandlerFromEndpoint instead. 81 // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. 82 func RegisterAllocationServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AllocationServiceServer) error { 83 mux.Handle(http.MethodPost, pattern_AllocationService_Allocate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 84 ctx, cancel := context.WithCancel(req.Context()) 85 defer cancel() 86 var stream runtime.ServerTransportStream 87 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 88 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 89 annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/allocation.AllocationService/Allocate", runtime.WithHTTPPathPattern("/gameserverallocation")) 90 if err != nil { 91 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 92 return 93 } 94 resp, md, err := local_request_AllocationService_Allocate_0(annotatedContext, inboundMarshaler, server, req, pathParams) 95 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 96 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 97 if err != nil { 98 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 99 return 100 } 101 forward_AllocationService_Allocate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 102 }) 103 104 return nil 105 } 106 107 // RegisterAllocationServiceHandlerFromEndpoint is same as RegisterAllocationServiceHandler but 108 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 109 func RegisterAllocationServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 110 conn, err := grpc.NewClient(endpoint, opts...) 111 if err != nil { 112 return err 113 } 114 defer func() { 115 if err != nil { 116 if cerr := conn.Close(); cerr != nil { 117 grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) 118 } 119 return 120 } 121 go func() { 122 <-ctx.Done() 123 if cerr := conn.Close(); cerr != nil { 124 grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) 125 } 126 }() 127 }() 128 return RegisterAllocationServiceHandler(ctx, mux, conn) 129 } 130 131 // RegisterAllocationServiceHandler registers the http handlers for service AllocationService to "mux". 132 // The handlers forward requests to the grpc endpoint over "conn". 133 func RegisterAllocationServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 134 return RegisterAllocationServiceHandlerClient(ctx, mux, NewAllocationServiceClient(conn)) 135 } 136 137 // RegisterAllocationServiceHandlerClient registers the http handlers for service AllocationService 138 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AllocationServiceClient". 139 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AllocationServiceClient" 140 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 141 // "AllocationServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. 142 func RegisterAllocationServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AllocationServiceClient) error { 143 mux.Handle(http.MethodPost, pattern_AllocationService_Allocate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 144 ctx, cancel := context.WithCancel(req.Context()) 145 defer cancel() 146 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 147 annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/allocation.AllocationService/Allocate", runtime.WithHTTPPathPattern("/gameserverallocation")) 148 if err != nil { 149 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 150 return 151 } 152 resp, md, err := request_AllocationService_Allocate_0(annotatedContext, inboundMarshaler, client, req, pathParams) 153 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 154 if err != nil { 155 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 156 return 157 } 158 forward_AllocationService_Allocate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 159 }) 160 return nil 161 } 162 163 var ( 164 pattern_AllocationService_Allocate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"gameserverallocation"}, "")) 165 ) 166 167 var ( 168 forward_AllocationService_Allocate_0 = runtime.ForwardResponseMessage 169 )