Skip to content

Commit

Permalink
set defaults on the config object
Browse files Browse the repository at this point in the history
  • Loading branch information
sethetter committed Feb 23, 2025
1 parent 8ed57a0 commit 00f30f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Config struct {
Email *EmailConfig
Twitter *TwitterConfig
SlackHook string `envconfig:"SLACK_HOOK"`
AdminUser string `envconfig:"ADMIN_USER"`
AdminPassword string `envconfig:"ADMIN_PASSWORD"`
AdminUser string `envconfig:"ADMIN_USER" required:"true" default:"admin"`
AdminPassword string `envconfig:"ADMIN_PASSWORD" require:"true" default:"password"`
}

type EmailConfig struct {
Expand Down
10 changes: 3 additions & 7 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,9 @@ func NewServer(c *ServerConfig) (http.Server, error) {

// Admin routes
admin := router.Group("/admin")

accounts := gin.Accounts{}
if c.Config.AdminUser != "" {
accounts[c.Config.AdminUser] = c.Config.AdminPassword
}

admin.Use(gin.BasicAuth(accounts))
admin.Use(gin.BasicAuth(gin.Accounts{
c.Config.AdminUser: c.Config.AdminPassword,
}))
{
admin.GET("", ctrl.AdminIndex)
admin.GET("/jobs/:id/edit", ctrl.EditJob)
Expand Down

0 comments on commit 00f30f9

Please sign in to comment.