go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/code-review-bot/main.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package main 9 10 import ( 11 "context" 12 "fmt" 13 14 "go.charczuk.com/sdk/apputil" 15 "go.charczuk.com/sdk/graceful" 16 "go.charczuk.com/sdk/logutil" 17 "go.charczuk.com/sdk/web" 18 19 "go.charczuk.com/projects/code-review-bot/pkg/config" 20 ) 21 22 var entrypoint = apputil.EntryPoint[config.Config]{ 23 Start: func(ctx context.Context, cfg config.Config) error { 24 log := logutil.GetLogger(ctx) 25 26 app := web.New() 27 app.RegisterConfig(cfg.Web) 28 app.RegisterLoggerListeners(log) 29 app.RegisterMiddleware(apputil.UpgradeHTTPS) 30 app.RegisterControllers() 31 32 if err := app.Initialize(); err != nil { 33 err = fmt.Errorf("app view initialization failure: %w", err) 34 return err 35 } 36 return graceful.StartForShutdown(ctx, 37 app, 38 ) 39 }, 40 } 41 42 func init() { 43 entrypoint.Init() 44 } 45 46 func main() { 47 entrypoint.Main() 48 }