fix: issues

This commit is contained in:
Rogee
2024-12-11 15:25:31 +08:00
parent 50bb28e90b
commit fefc9b2402
20 changed files with 2926 additions and 78 deletions

View File

@@ -15,6 +15,9 @@ import (
"git.ipao.vip/rogeecn/atom"
"git.ipao.vip/rogeecn/atom/container"
"git.ipao.vip/rogeecn/atom/contracts"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/favicon"
"github.com/gofiber/fiber/v3/middleware/static"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.uber.org/dig"
@@ -50,6 +53,7 @@ type Http struct {
dig.In
App *app.Config
Storage *storage.Config
Service *http.Service
Initials []contracts.Initial `group:"initials"`
Routes []contracts.HttpRoute `group:"routes"`
@@ -61,16 +65,31 @@ func Serve(cmd *cobra.Command, args []string) error {
if http.App.Mode == app.AppModeDevelopment {
log.SetLevel(log.DebugLevel)
}
engine := http.Service.Engine
mid := http.Middlewares
http.Service.Engine.Use(mid.DebugMode)
http.Service.Engine.Use(mid.ProcessResponse)
http.Service.Engine.Use(mid.WeChatVerify)
http.Service.Engine.Use(mid.WeChatAuthUserInfo)
http.Service.Engine.Use(mid.WeChatSilentAuth)
http.Service.Engine.Use(mid.ParseJWT)
engine.Use(mid.DebugMode)
engine.Use(mid.ProcessResponse)
wechatGroup := engine.Group("/t")
wechatGroup.Use(mid.WeChatVerify)
wechatGroup.Use(mid.WeChatAuthUserInfo)
wechatGroup.Use(mid.WeChatSilentAuth)
wechatGroup.Get("*", func(c fiber.Ctx) error {
return c.SendString("ok")
})
http.Service.Engine.Use(favicon.New(favicon.Config{
Data: []byte{},
}))
http.Service.Engine.Use("/static", static.New(http.Storage.Path, static.Config{
Browse: true,
}))
group := http.Service.Engine.Group("/v1")
group.Use(mid.ParseJWT)
for _, route := range http.Routes {
route.Register(group)
}

View File

@@ -7,6 +7,7 @@ import (
"backend/modules/medias"
"backend/modules/users"
"backend/providers/app"
"backend/providers/hashids"
"backend/providers/postgres"
"backend/providers/storage"
@@ -21,6 +22,7 @@ func defaultProviders(providers ...container.ProviderContainer) container.Provid
app.DefaultProvider(),
storage.DefaultProvider(),
postgres.DefaultProvider(),
hashids.DefaultProvider(),
}, providers...)
}