refactor: add unified all service gateway
This commit is contained in:
25
module/base/feedback/service/expose.go
Normal file
25
module/base/feedback/service/expose.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"bsm/full/module/base/feedback/internal/server"
|
||||
pb "bsm/full/module/base/feedback/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.RegisterMethodHandlerServer(ctx, options.Gateway, server.NewMethodServer()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user