Application superstructure (or supersingleton, if you want).
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Got rid of context thing which misleads due to existance of stdlib's context package. Also fixed golangci-lint configuration. Fixes #20.
This commit is contained in:
@@ -25,15 +25,15 @@
|
||||
package indexpage
|
||||
|
||||
import (
|
||||
"go.dev.pztrn.name/fastpastebin/internal/context"
|
||||
"go.dev.pztrn.name/fastpastebin/internal/application"
|
||||
)
|
||||
|
||||
var ctx *context.Context
|
||||
var app *application.Application
|
||||
|
||||
// New initializes pastes package and adds necessary HTTP and API
|
||||
// endpoints.
|
||||
func New(cc *context.Context) {
|
||||
ctx = cc
|
||||
func New(cc *application.Application) {
|
||||
app = cc
|
||||
|
||||
ctx.Echo.GET("/", indexGet)
|
||||
app.Echo.GET("/", indexGet)
|
||||
}
|
||||
|
@@ -37,8 +37,8 @@ import (
|
||||
// Index of this site.
|
||||
func indexGet(ectx echo.Context) error {
|
||||
// We should check if database connection available.
|
||||
dbConn := ctx.Database.GetDatabaseConnection()
|
||||
if ctx.Config.Database.Type != flatfiles.FlatFileDialect && dbConn == nil {
|
||||
dbConn := app.Database.GetDatabaseConnection()
|
||||
if app.Config.Database.Type != flatfiles.FlatFileDialect && dbConn == nil {
|
||||
//nolint:wrapcheck
|
||||
return ectx.Redirect(http.StatusFound, "/database_not_available")
|
||||
}
|
||||
|
Reference in New Issue
Block a user