add logics

This commit is contained in:
Rogee
2024-11-29 19:23:35 +08:00
parent dd0b6dd6c1
commit 3d7ee40a7a
12 changed files with 166 additions and 49 deletions

View File

@@ -1,6 +1,7 @@
package http
import (
"backend/modules/middlewares"
"backend/modules/users"
"backend/providers/app"
"backend/providers/http"
@@ -31,16 +32,19 @@ func Command() atom.Option {
atom.Name("serve"),
atom.Short("run http server"),
atom.RunE(Serve),
atom.Providers(providers),
atom.Providers(providers.With(
middlewares.Provide,
)),
)
}
type Http struct {
dig.In
Service *http.Service
Initials []contracts.Initial `group:"initials"`
Routes []contracts.HttpRoute `group:"routes"`
Service *http.Service
Initials []contracts.Initial `group:"initials"`
Routes []contracts.HttpRoute `group:"routes"`
Middlewares *middlewares.Middlewares
}
func Serve(cmd *cobra.Command, args []string) error {
@@ -51,6 +55,11 @@ func Serve(cmd *cobra.Command, args []string) error {
}
}
mid := http.Middlewares
http.Service.Engine.Use(mid.Verify)
http.Service.Engine.Use(mid.AuthUserInfo)
http.Service.Engine.Use(mid.SilentAuth)
return http.Service.Serve()
})
}