chore: stabilize lint and verify builds
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"quyun/v2/app/middlewares"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database"
|
||||
_ "quyun/v2/docs"
|
||||
docs "quyun/v2/docs"
|
||||
"quyun/v2/providers/app"
|
||||
"quyun/v2/providers/http"
|
||||
"quyun/v2/providers/http/swagger"
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
"go.ipao.vip/atom/contracts"
|
||||
|
||||
"github.com/gofiber/fiber/v3/middleware/favicon"
|
||||
log "github.com/sirupsen/logrus"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
@@ -65,31 +65,36 @@ type Service struct {
|
||||
|
||||
App *app.Config
|
||||
Job *job.Job
|
||||
Http *http.Service
|
||||
HTTP *http.Service
|
||||
DB *sql.DB
|
||||
Initials []contracts.Initial `group:"initials"`
|
||||
Routes []contracts.HttpRoute `group:"routes"`
|
||||
}
|
||||
|
||||
func Serve(cmd *cobra.Command, args []string) error {
|
||||
return container.Container.Invoke(func(ctx context.Context, svc Service) error {
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
func Serve(_ *cobra.Command, _ []string) error {
|
||||
if err := container.Container.Invoke(func(ctx context.Context, svc Service) error {
|
||||
_ = docs.SwaggerSpec
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
|
||||
if svc.App.Mode == app.AppModeDevelopment {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
|
||||
svc.Http.Engine.Get("/swagger/*", swagger.HandlerDefault)
|
||||
svc.HTTP.Engine.Get("/swagger/*", swagger.HandlerDefault)
|
||||
}
|
||||
svc.Http.Engine.Use(errorx.Middleware)
|
||||
svc.Http.Engine.Use(favicon.New(favicon.Config{
|
||||
svc.HTTP.Engine.Use(errorx.Middleware)
|
||||
svc.HTTP.Engine.Use(favicon.New(favicon.Config{
|
||||
Data: []byte{},
|
||||
}))
|
||||
|
||||
for _, route := range svc.Routes {
|
||||
group := svc.Http.Engine.Group(route.Path(), route.Middlewares()...).Name(route.Name())
|
||||
group := svc.HTTP.Engine.Group(route.Path(), route.Middlewares()...).Name(route.Name())
|
||||
route.Register(group)
|
||||
}
|
||||
|
||||
return svc.Http.Serve(ctx)
|
||||
})
|
||||
return svc.HTTP.Serve(ctx)
|
||||
}); err != nil {
|
||||
return errorx.ErrOperationFailed.WithCause(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user