api

package
v0.0.0-...-29697b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var EcommerceService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "ecommerce.EcommerceService",
	HandlerType: (*EcommerceServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Checkout",
			Handler:    _EcommerceService_Checkout_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "protos/api/ecommerce.proto",
}

EcommerceService_ServiceDesc is the grpc.ServiceDesc for EcommerceService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_protos_api_ecommerce_proto protoreflect.FileDescriptor

Functions

func RegisterEcommerceServiceHandler

func RegisterEcommerceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterEcommerceServiceHandler registers the http handlers for service EcommerceService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterEcommerceServiceHandlerClient

func RegisterEcommerceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EcommerceServiceClient) error

RegisterEcommerceServiceHandlerClient registers the http handlers for service EcommerceService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EcommerceServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EcommerceServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "EcommerceServiceClient" to call the correct interceptors.

func RegisterEcommerceServiceHandlerFromEndpoint

func RegisterEcommerceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterEcommerceServiceHandlerFromEndpoint is same as RegisterEcommerceServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterEcommerceServiceHandlerServer

func RegisterEcommerceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EcommerceServiceServer) error

RegisterEcommerceServiceHandlerServer registers the http handlers for service EcommerceService to "mux". UnaryRPC :call EcommerceServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterEcommerceServiceServer

func RegisterEcommerceServiceServer(s grpc.ServiceRegistrar, srv EcommerceServiceServer)

Types

type CheckoutRequest

type CheckoutRequest struct {
	Products []*ProductRequest `protobuf:"bytes,1,rep,name=products,proto3" json:"products,omitempty"`
	// contains filtered or unexported fields
}

func (*CheckoutRequest) Descriptor deprecated

func (*CheckoutRequest) Descriptor() ([]byte, []int)

Deprecated: Use CheckoutRequest.ProtoReflect.Descriptor instead.

func (*CheckoutRequest) GetProducts

func (x *CheckoutRequest) GetProducts() []*ProductRequest

func (*CheckoutRequest) ProtoMessage

func (*CheckoutRequest) ProtoMessage()

func (*CheckoutRequest) ProtoReflect

func (x *CheckoutRequest) ProtoReflect() protoreflect.Message

func (*CheckoutRequest) Reset

func (x *CheckoutRequest) Reset()

func (*CheckoutRequest) String

func (x *CheckoutRequest) String() string

type CheckoutResponse

type CheckoutResponse struct {
	TotalAmount             int32              `protobuf:"varint,1,opt,name=total_amount,json=totalAmount,proto3" json:"total_amount,omitempty"`
	TotalAmountWithDiscount int32              `` /* 135-byte string literal not displayed */
	TotalDiscount           int32              `protobuf:"varint,3,opt,name=total_discount,json=totalDiscount,proto3" json:"total_discount,omitempty"`
	Products                []*ProductResponse `protobuf:"bytes,4,rep,name=products,proto3" json:"products,omitempty"`
	// contains filtered or unexported fields
}

func (*CheckoutResponse) Descriptor deprecated

func (*CheckoutResponse) Descriptor() ([]byte, []int)

Deprecated: Use CheckoutResponse.ProtoReflect.Descriptor instead.

func (*CheckoutResponse) GetProducts

func (x *CheckoutResponse) GetProducts() []*ProductResponse

func (*CheckoutResponse) GetTotalAmount

func (x *CheckoutResponse) GetTotalAmount() int32

func (*CheckoutResponse) GetTotalAmountWithDiscount

func (x *CheckoutResponse) GetTotalAmountWithDiscount() int32

func (*CheckoutResponse) GetTotalDiscount

func (x *CheckoutResponse) GetTotalDiscount() int32

func (*CheckoutResponse) ProtoMessage

func (*CheckoutResponse) ProtoMessage()

func (*CheckoutResponse) ProtoReflect

func (x *CheckoutResponse) ProtoReflect() protoreflect.Message

func (*CheckoutResponse) Reset

func (x *CheckoutResponse) Reset()

func (*CheckoutResponse) String

func (x *CheckoutResponse) String() string

type EcommerceServiceClient

type EcommerceServiceClient interface {
	Checkout(ctx context.Context, in *CheckoutRequest, opts ...grpc.CallOption) (*CheckoutResponse, error)
}

EcommerceServiceClient is the client API for EcommerceService 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.

type EcommerceServiceServer

type EcommerceServiceServer interface {
	Checkout(context.Context, *CheckoutRequest) (*CheckoutResponse, error)
	// contains filtered or unexported methods
}

EcommerceServiceServer is the server API for EcommerceService service. All implementations must embed UnimplementedEcommerceServiceServer for forward compatibility

type ProductRequest

type ProductRequest struct {
	Id       int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Quantity int32 `protobuf:"varint,2,opt,name=quantity,proto3" json:"quantity,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductRequest) Descriptor deprecated

func (*ProductRequest) Descriptor() ([]byte, []int)

Deprecated: Use ProductRequest.ProtoReflect.Descriptor instead.

func (*ProductRequest) GetId

func (x *ProductRequest) GetId() int32

func (*ProductRequest) GetQuantity

func (x *ProductRequest) GetQuantity() int32

func (*ProductRequest) ProtoMessage

func (*ProductRequest) ProtoMessage()

func (*ProductRequest) ProtoReflect

func (x *ProductRequest) ProtoReflect() protoreflect.Message

func (*ProductRequest) Reset

func (x *ProductRequest) Reset()

func (*ProductRequest) String

func (x *ProductRequest) String() string

type ProductResponse

type ProductResponse struct {
	Id          int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Quantity    int32 `protobuf:"varint,2,opt,name=quantity,proto3" json:"quantity,omitempty"`
	UnitAmount  int32 `protobuf:"varint,3,opt,name=unit_amount,json=unitAmount,proto3" json:"unit_amount,omitempty"`
	TotalAmount int32 `protobuf:"varint,4,opt,name=total_amount,json=totalAmount,proto3" json:"total_amount,omitempty"`
	Discount    int32 `protobuf:"varint,5,opt,name=discount,proto3" json:"discount,omitempty"`
	IsGift      bool  `protobuf:"varint,6,opt,name=is_gift,json=isGift,proto3" json:"is_gift,omitempty"`
	// contains filtered or unexported fields
}

func (*ProductResponse) Descriptor deprecated

func (*ProductResponse) Descriptor() ([]byte, []int)

Deprecated: Use ProductResponse.ProtoReflect.Descriptor instead.

func (*ProductResponse) GetDiscount

func (x *ProductResponse) GetDiscount() int32

func (*ProductResponse) GetId

func (x *ProductResponse) GetId() int32

func (*ProductResponse) GetIsGift

func (x *ProductResponse) GetIsGift() bool

func (*ProductResponse) GetQuantity

func (x *ProductResponse) GetQuantity() int32

func (*ProductResponse) GetTotalAmount

func (x *ProductResponse) GetTotalAmount() int32

func (*ProductResponse) GetUnitAmount

func (x *ProductResponse) GetUnitAmount() int32

func (*ProductResponse) ProtoMessage

func (*ProductResponse) ProtoMessage()

func (*ProductResponse) ProtoReflect

func (x *ProductResponse) ProtoReflect() protoreflect.Message

func (*ProductResponse) Reset

func (x *ProductResponse) Reset()

func (*ProductResponse) String

func (x *ProductResponse) String() string

type UnimplementedEcommerceServiceServer

type UnimplementedEcommerceServiceServer struct {
}

UnimplementedEcommerceServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedEcommerceServiceServer) Checkout

type UnsafeEcommerceServiceServer

type UnsafeEcommerceServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeEcommerceServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to EcommerceServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL