Skip to content

Commit

Permalink
Add API for sending the config struct
Browse files Browse the repository at this point in the history
  • Loading branch information
haoming29 committed Oct 23, 2023
1 parent b65cc83 commit 047ba45
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions origin_ui/origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ func resetLoginHandler(ctx *gin.Context) {
}
}

func getConfig(ctx *gin.Context) {
config, err := param.GetUnmarshaledConfig()
if err != nil {
ctx.JSON(500, gin.H{"error": "Failed to get the unmarshaled config"})
return
}

ctx.JSON(200, config)
}

func ConfigureOriginUI(router *gin.Engine) error {
if router == nil {
return errors.New("Origin configuration passed a nil pointer")
Expand Down Expand Up @@ -389,6 +399,10 @@ func ConfigureOriginUI(router *gin.Engine) error {
}
})

// Register using router now. Can be converted to a group when more routes
// are added
router.GET("/api/v1.0/config", authHandler, getConfig)

router.GET("/view/*path", func(ctx *gin.Context) {
path := ctx.Param("path")

Expand Down

0 comments on commit 047ba45

Please sign in to comment.