Skip to content

Commit

Permalink
fix: correct some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
saman2000hoseini committed Jan 6, 2025
1 parent 581b331 commit 6bf464f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions internal/config-server/cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func main(cfg config.Config) {
app.GET("/healthz", func(c echo.Context) error { return c.NoContent(http.StatusNoContent) })

api := app.Group("/api")
api.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Enter path in order to retrieve config")
})
api.GET("/:endpoint", configHandler.Get)

if err := app.Start(fmt.Sprintf(":%d", cfg.API.Port)); !errors.Is(err, http.ErrServerClosed) {
Expand Down
14 changes: 9 additions & 5 deletions internal/handler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (h *Config) Get(c echo.Context) error {
return c.String(http.StatusInternalServerError, err.Error())
}

mergeMaps(config, engineConfig)
return c.JSON(http.StatusOK, mergeMaps(config, engineConfig))
}

return c.JSON(http.StatusOK, config)
Expand All @@ -35,12 +35,16 @@ func (h *Config) Get(c echo.Context) error {
func mergeMaps(cfg, engineCfg map[string]interface{}) map[string]interface{} {
merged := make(map[string]interface{})

for k, v := range engineCfg {
merged[k] = v
if engineCfg != nil {
for k, v := range engineCfg {
merged[k] = v
}
}

for k, v := range cfg {
merged[k] = v
if cfg != nil {
for k, v := range cfg {
merged[k] = v
}
}

return merged
Expand Down

0 comments on commit 6bf464f

Please sign in to comment.