feat: router run with PreRun
This commit is contained in:
parent
b2ad24762a
commit
7336d0d9d2
|
@ -136,6 +136,14 @@ func (r *Register) RegisterStruct(routers *Routers, drv interface{}, mws ...gin.
|
|||
}
|
||||
}
|
||||
|
||||
// PreRun 运行前动作
|
||||
func (r *Register) PreRun(f func() error) error {
|
||||
if f == nil {
|
||||
return nil
|
||||
}
|
||||
return f()
|
||||
}
|
||||
|
||||
// Run 服务运行
|
||||
func (r *Register) Run() {
|
||||
if r.addr == "" {
|
||||
|
|
|
@ -28,6 +28,11 @@ func TestRegister_getCallFunc(t *testing.T) {
|
|||
func TestNewRegister(t *testing.T) {
|
||||
var reg = NewRegister()
|
||||
reg.DefaultRouter(WithGinMode(gin.DebugMode))
|
||||
if err := reg.PreRun(func() error {
|
||||
return nil
|
||||
}); err != nil {
|
||||
// todo
|
||||
}
|
||||
// protoc core/file_module.proto --coco_out=core --go_out=core
|
||||
//reg.RegisterStruct(AutoGenFileRouterMap, &File{})
|
||||
reg.Run()
|
||||
|
|
Loading…
Reference in New Issue