refactor: add unified all service gateway
This commit is contained in:
34
module/ec/order/service/expose.go
Normal file
34
module/ec/order/service/expose.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"bsm/full/module/ec/order/internal/server"
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type ExposeOptions struct {
|
||||
GRPC *grpc.Server
|
||||
Gateway *gwRuntime.ServeMux
|
||||
}
|
||||
|
||||
func Expose(options ExposeOptions) error {
|
||||
server.New(options.GRPC)
|
||||
|
||||
ctx := context.Background()
|
||||
if err := pb.RegisterCartHandlerServer(ctx, options.Gateway, server.NewCartServer()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pb.RegisterCouponHandlerServer(ctx, options.Gateway, server.NewCouponServer()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pb.RegisterMgtHandlerServer(ctx, options.Gateway, server.NewMgtServer()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pb.RegisterSummaryHandlerServer(ctx, options.Gateway, server.NewSummaryServer()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user