This commit is contained in:
2025-06-17 11:16:24 +08:00
parent 6c3b4ec367
commit 759863f1aa
24 changed files with 103 additions and 92 deletions

View File

@@ -8,14 +8,14 @@ import (
"management/internal/pkg/render"
)
type App struct {
type app struct {
config *config.Config
render render.Renderer
captchaService v1.CaptchaService
}
func NewApp(config *config.Config, render render.Renderer, captchaService v1.CaptchaService) *App {
return &App{
func newApp(config *config.Config, render render.Renderer, captchaService v1.CaptchaService) *app {
return &app{
config: config,
render: render,
captchaService: captchaService,
@@ -29,7 +29,7 @@ type Response struct {
OpenCaptcha int `json:"open_captcha"`
}
func (a *App) captcha(w http.ResponseWriter, _ *http.Request) {
func (a *app) captcha(w http.ResponseWriter, _ *http.Request) {
id, b64s, _, err := a.captchaService.Generate(
a.config.Captcha.ImgHeight,
a.config.Captcha.ImgWidth,

View File

@@ -15,6 +15,6 @@ type Config struct {
}
func Routes(r chi.Router, cfg Config) {
app := NewApp(cfg.Conf, cfg.Render, cfg.CaptchaService)
app := newApp(cfg.Conf, cfg.Render, cfg.CaptchaService)
r.Get("/captcha", app.captcha)
}