go(refactor): clean up run.go
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4de0576c26
commit
72723d951d
@ -40,6 +40,13 @@ func (a *App) SetEchoSettings() {
|
||||
// TODO: have this in the config.
|
||||
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(20)))
|
||||
|
||||
// TODO: add check for prometheus config setting.
|
||||
// if true {
|
||||
// // import "github.com/labstack/echo-contrib/prometheus"
|
||||
// p := prometheus.NewPrometheus("echo", nil)
|
||||
// p.Use(e)
|
||||
// }
|
||||
|
||||
e.Use(middleware.Recover())
|
||||
|
||||
e.Use(session.Middleware(
|
||||
|
28
run.go
28
run.go
@ -120,11 +120,12 @@ func run() error {
|
||||
case dbtype != "postgres" && dbtype != "sqlite3":
|
||||
log.Errorf("unsupported DB type specified, bailing...")
|
||||
return errUnsupportedDBType
|
||||
}
|
||||
|
||||
setting.SetDbConnstring(connstr)
|
||||
// type can be one of "postgres" or "sqlite3".
|
||||
setting.SetDbType(dbtype)
|
||||
default:
|
||||
setting.SetDbConnstring(connstr)
|
||||
// type can be one of "postgres" or "sqlite3".
|
||||
setting.SetDbType(dbtype)
|
||||
}
|
||||
|
||||
log.Infof("connecting to db at '%s'", connstr)
|
||||
|
||||
@ -138,8 +139,7 @@ func run() error {
|
||||
|
||||
log.Info("making sure that the db is set up")
|
||||
|
||||
err = moddb.SetUp(ctx, db)
|
||||
if err != nil {
|
||||
if err = moddb.SetUp(ctx, db); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -153,30 +153,16 @@ func run() error {
|
||||
|
||||
a := &app.App{}
|
||||
|
||||
err = a.Init(setting, slogger, db)
|
||||
if err != nil {
|
||||
if err = a.Init(setting, slogger, db); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.PrintConfiguration()
|
||||
|
||||
a.SetEmbeds(templates, assets)
|
||||
|
||||
a.SetupRoutes()
|
||||
|
||||
a.SetEchoSettings()
|
||||
|
||||
// a.SetConfig(conf)
|
||||
|
||||
// // TODO: add check for prometheus config setting.
|
||||
// if true {
|
||||
// // import "github.com/labstack/echo-contrib/prometheus"
|
||||
// p := prometheus.NewPrometheus("echo", nil)
|
||||
// p.Use(e)
|
||||
// }
|
||||
|
||||
e := a.E()
|
||||
|
||||
// channel used to check whether the app had troubles starting up.
|
||||
started := make(chan error, 1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user