agones.dev/agones@v1.54.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 if req.Body != nil { 62 _, _ = io.Copy(io.Discard, req.Body) 63 } 64 msg, err := client.Allocate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 65 return msg, metadata, err 66 } 67 68 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) { 69 var ( 70 protoReq AllocationRequest 71 metadata runtime.ServerMetadata 72 ) 73 if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { 74 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 75 } 76 msg, err := server.Allocate(ctx, &protoReq) 77 return msg, metadata, err 78 } 79 80 // RegisterAllocationServiceHandlerServer registers the http handlers for service AllocationService to "mux". 81 // UnaryRPC :call AllocationServiceServer directly. 82 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 83 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAllocationServiceHandlerFromEndpoint instead. 84 // 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. 85 func RegisterAllocationServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AllocationServiceServer) error { 86 mux.Handle(http.MethodPost, pattern_AllocationService_Allocate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 87 ctx, cancel := context.WithCancel(req.Context()) 88 defer cancel() 89 var stream runtime.ServerTransportStream 90 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 91 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 92 annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/allocation.AllocationService/Allocate", runtime.WithHTTPPathPattern("/gameserverallocation")) 93 if err != nil { 94 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 95 return 96 } 97 resp, md, err := local_request_AllocationService_Allocate_0(annotatedContext, inboundMarshaler, server, req, pathParams) 98 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 99 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 100 if err != nil { 101 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 102 return 103 } 104 forward_AllocationService_Allocate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 105 }) 106 107 return nil 108 } 109 110 // RegisterAllocationServiceHandlerFromEndpoint is same as RegisterAllocationServiceHandler but 111 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 112 func RegisterAllocationServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 113 conn, err := grpc.NewClient(endpoint, opts...) 114 if err != nil { 115 return err 116 } 117 defer func() { 118 if err != nil { 119 if cerr := conn.Close(); cerr != nil { 120 grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) 121 } 122 return 123 } 124 go func() { 125 <-ctx.Done() 126 if cerr := conn.Close(); cerr != nil { 127 grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) 128 } 129 }() 130 }() 131 return RegisterAllocationServiceHandler(ctx, mux, conn) 132 } 133 134 // RegisterAllocationServiceHandler registers the http handlers for service AllocationService to "mux". 135 // The handlers forward requests to the grpc endpoint over "conn". 136 func RegisterAllocationServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 137 return RegisterAllocationServiceHandlerClient(ctx, mux, NewAllocationServiceClient(conn)) 138 } 139 140 // RegisterAllocationServiceHandlerClient registers the http handlers for service AllocationService 141 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AllocationServiceClient". 142 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AllocationServiceClient" 143 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 144 // "AllocationServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. 145 func RegisterAllocationServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AllocationServiceClient) error { 146 mux.Handle(http.MethodPost, pattern_AllocationService_Allocate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 147 ctx, cancel := context.WithCancel(req.Context()) 148 defer cancel() 149 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 150 annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/allocation.AllocationService/Allocate", runtime.WithHTTPPathPattern("/gameserverallocation")) 151 if err != nil { 152 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 153 return 154 } 155 resp, md, err := request_AllocationService_Allocate_0(annotatedContext, inboundMarshaler, client, req, pathParams) 156 annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) 157 if err != nil { 158 runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) 159 return 160 } 161 forward_AllocationService_Allocate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 162 }) 163 return nil 164 } 165 166 var ( 167 pattern_AllocationService_Allocate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"gameserverallocation"}, "")) 168 ) 169 170 var ( 171 forward_AllocationService_Allocate_0 = runtime.ForwardResponseMessage 172 )