github.com/zorawar87/trillian@v1.2.1/trillian_map_api.pb.gw.go (about) 1 // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. 2 // source: trillian_map_api.proto 3 4 /* 5 Package trillian is a reverse proxy. 6 7 It translates gRPC into RESTful JSON APIs. 8 */ 9 package trillian 10 11 import ( 12 "io" 13 "net/http" 14 15 "github.com/golang/protobuf/proto" 16 "github.com/grpc-ecosystem/grpc-gateway/runtime" 17 "github.com/grpc-ecosystem/grpc-gateway/utilities" 18 "golang.org/x/net/context" 19 "google.golang.org/grpc" 20 "google.golang.org/grpc/codes" 21 "google.golang.org/grpc/grpclog" 22 "google.golang.org/grpc/status" 23 ) 24 25 var _ codes.Code 26 var _ io.Reader 27 var _ status.Status 28 var _ = runtime.String 29 var _ = utilities.NewDoubleArray 30 31 func request_TrillianMap_GetSignedMapRoot_0(ctx context.Context, marshaler runtime.Marshaler, client TrillianMapClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 32 var protoReq GetSignedMapRootRequest 33 var metadata runtime.ServerMetadata 34 35 var ( 36 val string 37 ok bool 38 err error 39 _ = err 40 ) 41 42 val, ok = pathParams["map_id"] 43 if !ok { 44 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "map_id") 45 } 46 47 protoReq.MapId, err = runtime.Int64(val) 48 49 if err != nil { 50 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "map_id", err) 51 } 52 53 msg, err := client.GetSignedMapRoot(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 54 return msg, metadata, err 55 56 } 57 58 func request_TrillianMap_GetSignedMapRootByRevision_0(ctx context.Context, marshaler runtime.Marshaler, client TrillianMapClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 59 var protoReq GetSignedMapRootByRevisionRequest 60 var metadata runtime.ServerMetadata 61 62 var ( 63 val string 64 ok bool 65 err error 66 _ = err 67 ) 68 69 val, ok = pathParams["map_id"] 70 if !ok { 71 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "map_id") 72 } 73 74 protoReq.MapId, err = runtime.Int64(val) 75 76 if err != nil { 77 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "map_id", err) 78 } 79 80 val, ok = pathParams["revision"] 81 if !ok { 82 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "revision") 83 } 84 85 protoReq.Revision, err = runtime.Int64(val) 86 87 if err != nil { 88 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "revision", err) 89 } 90 91 msg, err := client.GetSignedMapRootByRevision(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 92 return msg, metadata, err 93 94 } 95 96 func request_TrillianMap_InitMap_0(ctx context.Context, marshaler runtime.Marshaler, client TrillianMapClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 97 var protoReq InitMapRequest 98 var metadata runtime.ServerMetadata 99 100 var ( 101 val string 102 ok bool 103 err error 104 _ = err 105 ) 106 107 val, ok = pathParams["map_id"] 108 if !ok { 109 return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "map_id") 110 } 111 112 protoReq.MapId, err = runtime.Int64(val) 113 114 if err != nil { 115 return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "map_id", err) 116 } 117 118 msg, err := client.InitMap(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 119 return msg, metadata, err 120 121 } 122 123 // RegisterTrillianMapHandlerFromEndpoint is same as RegisterTrillianMapHandler but 124 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 125 func RegisterTrillianMapHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 126 conn, err := grpc.Dial(endpoint, opts...) 127 if err != nil { 128 return err 129 } 130 defer func() { 131 if err != nil { 132 if cerr := conn.Close(); cerr != nil { 133 grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) 134 } 135 return 136 } 137 go func() { 138 <-ctx.Done() 139 if cerr := conn.Close(); cerr != nil { 140 grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) 141 } 142 }() 143 }() 144 145 return RegisterTrillianMapHandler(ctx, mux, conn) 146 } 147 148 // RegisterTrillianMapHandler registers the http handlers for service TrillianMap to "mux". 149 // The handlers forward requests to the grpc endpoint over "conn". 150 func RegisterTrillianMapHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 151 return RegisterTrillianMapHandlerClient(ctx, mux, NewTrillianMapClient(conn)) 152 } 153 154 // RegisterTrillianMapHandler registers the http handlers for service TrillianMap to "mux". 155 // The handlers forward requests to the grpc endpoint over the given implementation of "TrillianMapClient". 156 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TrillianMapClient" 157 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 158 // "TrillianMapClient" to call the correct interceptors. 159 func RegisterTrillianMapHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TrillianMapClient) error { 160 161 mux.Handle("GET", pattern_TrillianMap_GetSignedMapRoot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 162 ctx, cancel := context.WithCancel(req.Context()) 163 defer cancel() 164 if cn, ok := w.(http.CloseNotifier); ok { 165 go func(done <-chan struct{}, closed <-chan bool) { 166 select { 167 case <-done: 168 case <-closed: 169 cancel() 170 } 171 }(ctx.Done(), cn.CloseNotify()) 172 } 173 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 174 rctx, err := runtime.AnnotateContext(ctx, mux, req) 175 if err != nil { 176 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 177 return 178 } 179 resp, md, err := request_TrillianMap_GetSignedMapRoot_0(rctx, inboundMarshaler, client, req, pathParams) 180 ctx = runtime.NewServerMetadataContext(ctx, md) 181 if err != nil { 182 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 183 return 184 } 185 186 forward_TrillianMap_GetSignedMapRoot_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 187 188 }) 189 190 mux.Handle("GET", pattern_TrillianMap_GetSignedMapRootByRevision_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 191 ctx, cancel := context.WithCancel(req.Context()) 192 defer cancel() 193 if cn, ok := w.(http.CloseNotifier); ok { 194 go func(done <-chan struct{}, closed <-chan bool) { 195 select { 196 case <-done: 197 case <-closed: 198 cancel() 199 } 200 }(ctx.Done(), cn.CloseNotify()) 201 } 202 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 203 rctx, err := runtime.AnnotateContext(ctx, mux, req) 204 if err != nil { 205 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 206 return 207 } 208 resp, md, err := request_TrillianMap_GetSignedMapRootByRevision_0(rctx, inboundMarshaler, client, req, pathParams) 209 ctx = runtime.NewServerMetadataContext(ctx, md) 210 if err != nil { 211 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 212 return 213 } 214 215 forward_TrillianMap_GetSignedMapRootByRevision_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 216 217 }) 218 219 mux.Handle("POST", pattern_TrillianMap_InitMap_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 220 ctx, cancel := context.WithCancel(req.Context()) 221 defer cancel() 222 if cn, ok := w.(http.CloseNotifier); ok { 223 go func(done <-chan struct{}, closed <-chan bool) { 224 select { 225 case <-done: 226 case <-closed: 227 cancel() 228 } 229 }(ctx.Done(), cn.CloseNotify()) 230 } 231 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 232 rctx, err := runtime.AnnotateContext(ctx, mux, req) 233 if err != nil { 234 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 235 return 236 } 237 resp, md, err := request_TrillianMap_InitMap_0(rctx, inboundMarshaler, client, req, pathParams) 238 ctx = runtime.NewServerMetadataContext(ctx, md) 239 if err != nil { 240 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 241 return 242 } 243 244 forward_TrillianMap_InitMap_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 245 246 }) 247 248 return nil 249 } 250 251 var ( 252 pattern_TrillianMap_GetSignedMapRoot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"v1beta1", "maps", "map_id", "roots"}, "latest")) 253 254 pattern_TrillianMap_GetSignedMapRootByRevision_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1beta1", "maps", "map_id", "roots", "revision"}, "")) 255 256 pattern_TrillianMap_InitMap_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1beta1", "maps", "map_id"}, "init")) 257 ) 258 259 var ( 260 forward_TrillianMap_GetSignedMapRoot_0 = runtime.ForwardResponseMessage 261 262 forward_TrillianMap_GetSignedMapRootByRevision_0 = runtime.ForwardResponseMessage 263 264 forward_TrillianMap_InitMap_0 = runtime.ForwardResponseMessage 265 )