Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ func main() {
flag.BoolVar(&showVersion, "version", false, "Show version information")
flag.BoolVar(&showVersion, "v", false, "Show version information")

var configPath string
var (
configPath string
debug bool
)
flag.StringVar(&configPath, "config", "", "Path to configuration file")
flag.BoolVar(&debug, "debug", false, "Enable debug mode for Gin framework")
flag.Parse()

// Show version if requested
Expand Down Expand Up @@ -75,7 +79,7 @@ func main() {
ghcrCollector.Start(ctx)

// Create and start server
srv := server.New(cfg, metricsRegistry)
srv := server.New(cfg, metricsRegistry, debug)

// Handle graceful shutdown
sigChan := make(chan os.Signal, 1)
Expand Down
5 changes: 3 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ type GitHubConfig struct {
}

type ServerConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Debug bool `yaml:"debug"`
}

type LoggingConfig struct {
Expand Down
9 changes: 8 additions & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ type Server struct {
router *gin.Engine
}

func New(cfg *config.Config, metricsRegistry *metrics.Registry) *Server {
func New(cfg *config.Config, metricsRegistry *metrics.Registry, debug bool) *Server {
// Set Gin mode based on debug flag or config
if debug || cfg.Server.Debug {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}

router := gin.New()
router.Use(gin.Recovery())

Expand Down