feat: update http service

This commit is contained in:
rogeecn
2025-02-28 09:20:31 +08:00
parent f9400aff1a
commit 5b5a28b4bb
2 changed files with 32 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ type Service struct {
App *app.Config
Job *job.Job
Service *http.Service
Http *http.Service
Initials []contracts.Initial `group:"initials"`
Routes []contracts.HttpRoute `group:"routes"`
}
@@ -65,18 +65,18 @@ func Serve(cmd *cobra.Command, args []string) error {
if svc.App.Mode == app.AppModeDevelopment {
log.SetLevel(log.DebugLevel)
svc.Service.Engine.Get("/swagger/*", swagger.HandlerDefault)
svc.Http.Engine.Get("/swagger/*", swagger.HandlerDefault)
}
svc.Service.Engine.Use(errorx.Middleware)
svc.Service.Engine.Use(favicon.New(favicon.Config{
svc.Http.Engine.Use(errorx.Middleware)
svc.Http.Engine.Use(favicon.New(favicon.Config{
Data: []byte{},
}))
group := svc.Service.Engine.Group("")
group := svc.Http.Engine.Group("")
for _, route := range svc.Routes {
route.Register(group)
}
return svc.Service.Serve()
return svc.Http.Serve()
})
}