Documentation ¶
Overview ¶
Package product is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterProductServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterProductServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ProductServiceClient) error
- func RegisterProductServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterProductServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ProductServiceServer) error
- func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer)
- type Aggregation
- type CreateProductBody
- func (*CreateProductBody) Descriptor() ([]byte, []int)deprecated
- func (x *CreateProductBody) GetDescription() string
- func (x *CreateProductBody) GetName() string
- func (x *CreateProductBody) GetPrice() float64
- func (*CreateProductBody) ProtoMessage()
- func (x *CreateProductBody) ProtoReflect() protoreflect.Message
- func (x *CreateProductBody) Reset()
- func (x *CreateProductBody) String() string
- type GetProductResponse
- func (*GetProductResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetProductResponse) GetProduct() *Product
- func (*GetProductResponse) ProtoMessage()
- func (x *GetProductResponse) ProtoReflect() protoreflect.Message
- func (x *GetProductResponse) Reset()
- func (x *GetProductResponse) String() string
- type ListProductsResponse
- func (*ListProductsResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ListProductsResponse) GetProducts() []*Product
- func (*ListProductsResponse) ProtoMessage()
- func (x *ListProductsResponse) ProtoReflect() protoreflect.Message
- func (x *ListProductsResponse) Reset()
- func (x *ListProductsResponse) String() string
- type Page
- type Product
- func (*Product) Descriptor() ([]byte, []int)deprecated
- func (x *Product) GetDescription() string
- func (x *Product) GetId() string
- func (x *Product) GetName() string
- func (x *Product) GetPrice() float64
- func (*Product) ProtoMessage()
- func (x *Product) ProtoReflect() protoreflect.Message
- func (x *Product) Reset()
- func (x *Product) String() string
- type ProductId
- type ProductParams
- func (*ProductParams) Descriptor() ([]byte, []int)deprecated
- func (x *ProductParams) GetName() *Aggregation
- func (x *ProductParams) GetPage() *Page
- func (*ProductParams) ProtoMessage()
- func (x *ProductParams) ProtoReflect() protoreflect.Message
- func (x *ProductParams) Reset()
- func (x *ProductParams) String() string
- type ProductServiceClient
- type ProductServiceServer
- type UnimplementedProductServiceServer
- func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductBody) (*proto.Message, error)
- func (UnimplementedProductServiceServer) DeleteProduct(context.Context, *ProductId) (*proto.Message, error)
- func (UnimplementedProductServiceServer) GetProduct(context.Context, *ProductId) (*GetProductResponse, error)
- func (UnimplementedProductServiceServer) GetProducts(context.Context, *ProductParams) (*ListProductsResponse, error)
- type UnsafeProductServiceServer
Constants ¶
const ( ProductService_CreateProduct_FullMethodName = "/grpc.gateway.example.internal.adapter.api.v1.product.ProductService/CreateProduct" ProductService_GetProducts_FullMethodName = "/grpc.gateway.example.internal.adapter.api.v1.product.ProductService/GetProducts" ProductService_GetProduct_FullMethodName = "/grpc.gateway.example.internal.adapter.api.v1.product.ProductService/GetProduct" ProductService_DeleteProduct_FullMethodName = "/grpc.gateway.example.internal.adapter.api.v1.product.ProductService/DeleteProduct" )
Variables ¶
var File_internal_adapter_api_v1_product_product_proto protoreflect.FileDescriptor
var ProductService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.example.internal.adapter.api.v1.product.ProductService", HandlerType: (*ProductServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CreateProduct", Handler: _ProductService_CreateProduct_Handler, }, { MethodName: "GetProducts", Handler: _ProductService_GetProducts_Handler, }, { MethodName: "GetProduct", Handler: _ProductService_GetProduct_Handler, }, { MethodName: "DeleteProduct", Handler: _ProductService_DeleteProduct_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "internal/adapter/api/v1/product/product.proto", }
ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterProductServiceHandler ¶
func RegisterProductServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterProductServiceHandler registers the http handlers for service ProductService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterProductServiceHandlerClient ¶
func RegisterProductServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ProductServiceClient) error
RegisterProductServiceHandlerClient registers the http handlers for service ProductService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ProductServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ProductServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ProductServiceClient" to call the correct interceptors.
func RegisterProductServiceHandlerFromEndpoint ¶
func RegisterProductServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterProductServiceHandlerFromEndpoint is same as RegisterProductServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterProductServiceHandlerServer ¶
func RegisterProductServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ProductServiceServer) error
RegisterProductServiceHandlerServer registers the http handlers for service ProductService to "mux". UnaryRPC :call ProductServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterProductServiceHandlerFromEndpoint instead.
func RegisterProductServiceServer ¶
func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer)
Types ¶
type Aggregation ¶
type Aggregation struct { Eq *string `protobuf:"bytes,1,opt,name=eq,proto3,oneof" json:"eq,omitempty"` Like *string `protobuf:"bytes,2,opt,name=like,proto3,oneof" json:"like,omitempty"` // contains filtered or unexported fields }
func (*Aggregation) Descriptor
deprecated
func (*Aggregation) Descriptor() ([]byte, []int)
Deprecated: Use Aggregation.ProtoReflect.Descriptor instead.
func (*Aggregation) GetEq ¶
func (x *Aggregation) GetEq() string
func (*Aggregation) GetLike ¶
func (x *Aggregation) GetLike() string
func (*Aggregation) ProtoMessage ¶
func (*Aggregation) ProtoMessage()
func (*Aggregation) ProtoReflect ¶
func (x *Aggregation) ProtoReflect() protoreflect.Message
func (*Aggregation) Reset ¶
func (x *Aggregation) Reset()
func (*Aggregation) String ¶
func (x *Aggregation) String() string
type CreateProductBody ¶
type CreateProductBody struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` Price float64 `protobuf:"fixed64,3,opt,name=price,proto3" json:"price,omitempty"` // contains filtered or unexported fields }
func (*CreateProductBody) Descriptor
deprecated
func (*CreateProductBody) Descriptor() ([]byte, []int)
Deprecated: Use CreateProductBody.ProtoReflect.Descriptor instead.
func (*CreateProductBody) GetDescription ¶
func (x *CreateProductBody) GetDescription() string
func (*CreateProductBody) GetName ¶
func (x *CreateProductBody) GetName() string
func (*CreateProductBody) GetPrice ¶
func (x *CreateProductBody) GetPrice() float64
func (*CreateProductBody) ProtoMessage ¶
func (*CreateProductBody) ProtoMessage()
func (*CreateProductBody) ProtoReflect ¶
func (x *CreateProductBody) ProtoReflect() protoreflect.Message
func (*CreateProductBody) Reset ¶
func (x *CreateProductBody) Reset()
func (*CreateProductBody) String ¶
func (x *CreateProductBody) String() string
type GetProductResponse ¶
type GetProductResponse struct { Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"` // contains filtered or unexported fields }
func (*GetProductResponse) Descriptor
deprecated
func (*GetProductResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetProductResponse.ProtoReflect.Descriptor instead.
func (*GetProductResponse) GetProduct ¶
func (x *GetProductResponse) GetProduct() *Product
func (*GetProductResponse) ProtoMessage ¶
func (*GetProductResponse) ProtoMessage()
func (*GetProductResponse) ProtoReflect ¶
func (x *GetProductResponse) ProtoReflect() protoreflect.Message
func (*GetProductResponse) Reset ¶
func (x *GetProductResponse) Reset()
func (*GetProductResponse) String ¶
func (x *GetProductResponse) String() string
type ListProductsResponse ¶
type ListProductsResponse struct { Products []*Product `protobuf:"bytes,1,rep,name=products,proto3" json:"products,omitempty"` // contains filtered or unexported fields }
func (*ListProductsResponse) Descriptor
deprecated
func (*ListProductsResponse) Descriptor() ([]byte, []int)
Deprecated: Use ListProductsResponse.ProtoReflect.Descriptor instead.
func (*ListProductsResponse) GetProducts ¶
func (x *ListProductsResponse) GetProducts() []*Product
func (*ListProductsResponse) ProtoMessage ¶
func (*ListProductsResponse) ProtoMessage()
func (*ListProductsResponse) ProtoReflect ¶
func (x *ListProductsResponse) ProtoReflect() protoreflect.Message
func (*ListProductsResponse) Reset ¶
func (x *ListProductsResponse) Reset()
func (*ListProductsResponse) String ¶
func (x *ListProductsResponse) String() string
type Page ¶
type Page struct { Size *string `protobuf:"bytes,1,opt,name=size,proto3,oneof" json:"size,omitempty"` Eq *string `protobuf:"bytes,2,opt,name=eq,proto3,oneof" json:"eq,omitempty"` // contains filtered or unexported fields }
func (*Page) Descriptor
deprecated
func (*Page) ProtoMessage ¶
func (*Page) ProtoMessage()
func (*Page) ProtoReflect ¶
func (x *Page) ProtoReflect() protoreflect.Message
type Product ¶
type Product struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` Price float64 `protobuf:"fixed64,4,opt,name=price,proto3" json:"price,omitempty"` // contains filtered or unexported fields }
func (*Product) Descriptor
deprecated
func (*Product) GetDescription ¶
func (*Product) ProtoMessage ¶
func (*Product) ProtoMessage()
func (*Product) ProtoReflect ¶
func (x *Product) ProtoReflect() protoreflect.Message
type ProductId ¶
type ProductId struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // contains filtered or unexported fields }
func (*ProductId) Descriptor
deprecated
func (*ProductId) ProtoMessage ¶
func (*ProductId) ProtoMessage()
func (*ProductId) ProtoReflect ¶
func (x *ProductId) ProtoReflect() protoreflect.Message
type ProductParams ¶
type ProductParams struct { Page *Page `protobuf:"bytes,1,opt,name=page,proto3,oneof" json:"page,omitempty"` Name *Aggregation `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"` // contains filtered or unexported fields }
func (*ProductParams) Descriptor
deprecated
func (*ProductParams) Descriptor() ([]byte, []int)
Deprecated: Use ProductParams.ProtoReflect.Descriptor instead.
func (*ProductParams) GetName ¶
func (x *ProductParams) GetName() *Aggregation
func (*ProductParams) GetPage ¶
func (x *ProductParams) GetPage() *Page
func (*ProductParams) ProtoMessage ¶
func (*ProductParams) ProtoMessage()
func (*ProductParams) ProtoReflect ¶
func (x *ProductParams) ProtoReflect() protoreflect.Message
func (*ProductParams) Reset ¶
func (x *ProductParams) Reset()
func (*ProductParams) String ¶
func (x *ProductParams) String() string
type ProductServiceClient ¶
type ProductServiceClient interface { CreateProduct(ctx context.Context, in *CreateProductBody, opts ...grpc.CallOption) (*proto.Message, error) GetProducts(ctx context.Context, in *ProductParams, opts ...grpc.CallOption) (*ListProductsResponse, error) GetProduct(ctx context.Context, in *ProductId, opts ...grpc.CallOption) (*GetProductResponse, error) DeleteProduct(ctx context.Context, in *ProductId, opts ...grpc.CallOption) (*proto.Message, error) }
ProductServiceClient is the client API for ProductService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewProductServiceClient ¶
func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient
type ProductServiceServer ¶
type ProductServiceServer interface { CreateProduct(context.Context, *CreateProductBody) (*proto.Message, error) GetProducts(context.Context, *ProductParams) (*ListProductsResponse, error) GetProduct(context.Context, *ProductId) (*GetProductResponse, error) DeleteProduct(context.Context, *ProductId) (*proto.Message, error) // contains filtered or unexported methods }
ProductServiceServer is the server API for ProductService service. All implementations must embed UnimplementedProductServiceServer for forward compatibility
func NewServer ¶
func NewServer(productService service.ProductService, logger logging.Logger) ProductServiceServer
type UnimplementedProductServiceServer ¶
type UnimplementedProductServiceServer struct { }
UnimplementedProductServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedProductServiceServer) CreateProduct ¶
func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductBody) (*proto.Message, error)
func (UnimplementedProductServiceServer) DeleteProduct ¶
func (UnimplementedProductServiceServer) GetProduct ¶
func (UnimplementedProductServiceServer) GetProduct(context.Context, *ProductId) (*GetProductResponse, error)
func (UnimplementedProductServiceServer) GetProducts ¶
func (UnimplementedProductServiceServer) GetProducts(context.Context, *ProductParams) (*ListProductsResponse, error)
type UnsafeProductServiceServer ¶
type UnsafeProductServiceServer interface {
// contains filtered or unexported methods
}
UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ProductServiceServer will result in compilation errors.