-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(template): fix gateway template dynamic conf feature
fix(template): fix gateway template dynamic conf feature fix(template): fix gateway template dynamic conf feature fix(template): fix gateway template dynamic conf feature fix(template): fix gateway template dynamic conf feature fix(template): fix gateway template dynamic conf feature
- Loading branch information
Showing
5 changed files
with
29 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
package custom | ||
|
||
import ( | ||
"os" | ||
"os" | ||
|
||
"{{.Module}}/internal/config" | ||
configurator "github.com/zeromicro/go-zero/core/configcenter" | ||
|
||
"{{.Module}}/internal/config" | ||
) | ||
|
||
type Custom struct{} | ||
type Custom struct { | ||
Config configurator.Configurator[config.Config] | ||
} | ||
|
||
func New() *Custom { | ||
return &Custom{} | ||
func New(config configurator.Configurator[config.Config]) *Custom { | ||
return &Custom{Config: config} | ||
} | ||
|
||
// Start Please add custom logic here. | ||
func (c *Custom) Start() {} | ||
|
||
// Stop Please add shut down logic here. | ||
func (c *Custom) Stop() { | ||
// remove temp pb file | ||
if len(config.C.Gateway.Upstreams) > 0 { | ||
for _, p := range config.C.Gateway.Upstreams[0].ProtoSets { | ||
_ = os.Remove(p) | ||
conf, err := c.Config.GetConfig() | ||
if err == nil { | ||
// remove temp pb file | ||
if len(conf.Gateway.Upstreams) > 0 { | ||
for _, p := range conf.Gateway.Upstreams[0].ProtoSets { | ||
_ = os.Remove(p) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters