Application superstructure (or supersingleton, if you want).
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:
2022-08-19 21:52:49 +05:00
parent b87921c811
commit 5fc6d3a181
35 changed files with 589 additions and 440 deletions

View File

@@ -28,22 +28,22 @@ import (
"github.com/dchest/captcha"
"github.com/labstack/echo"
"github.com/rs/zerolog"
"go.dev.pztrn.name/fastpastebin/internal/context"
"go.dev.pztrn.name/fastpastebin/internal/application"
)
var (
ctx *context.Context
app *application.Application
log zerolog.Logger
)
// New initializes captcha package and adds necessary HTTP and API
// endpoints.
func New(cc *context.Context) {
ctx = cc
log = ctx.Logger.With().Str("type", "internal").Str("package", "captcha").Logger()
func New(cc *application.Application) {
app = cc
log = app.Log.With().Str("type", "internal").Str("package", "captcha").Logger()
// New paste.
ctx.Echo.GET("/captcha/:id.png", echo.WrapHandler(captcha.Server(captcha.StdWidth, captcha.StdHeight)))
app.Echo.GET("/captcha/:id.png", echo.WrapHandler(captcha.Server(captcha.StdWidth, captcha.StdHeight)))
}
// NewCaptcha creates new captcha string.