fix: mp verify
This commit is contained in:
@@ -54,11 +54,13 @@ func Provide(opts ...opt.Option) error {
|
||||
auth *auth,
|
||||
pays *pays,
|
||||
posts *posts,
|
||||
weChat *weChat,
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
auth: auth,
|
||||
pays: pays,
|
||||
posts: posts,
|
||||
auth: auth,
|
||||
pays: pays,
|
||||
posts: posts,
|
||||
weChat: weChat,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
@@ -68,5 +70,12 @@ func Provide(opts ...opt.Option) error {
|
||||
}, atom.GroupRoutes); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*weChat, error) {
|
||||
obj := &weChat{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@ import (
|
||||
|
||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||
type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
auth *auth
|
||||
pays *pays
|
||||
posts *posts
|
||||
log *log.Entry `inject:"false"`
|
||||
auth *auth
|
||||
pays *pays
|
||||
posts *posts
|
||||
weChat *weChat
|
||||
}
|
||||
|
||||
func (r *Routes) Prepare() error {
|
||||
@@ -74,4 +75,10 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
Local[*model.Users]("user"),
|
||||
))
|
||||
|
||||
// 注册路由组: weChat
|
||||
router.Get("/MP_verify_:code.txt", Func1(
|
||||
r.weChat.Verify,
|
||||
PathParam[string]("code"),
|
||||
))
|
||||
|
||||
}
|
||||
|
||||
13
backend/app/http/wechat.go
Normal file
13
backend/app/http/wechat.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package http
|
||||
|
||||
import "github.com/gofiber/fiber/v3"
|
||||
|
||||
// @provider
|
||||
type weChat struct{}
|
||||
|
||||
// Verify
|
||||
// @Router /MP_verify_:code.txt [get]
|
||||
// @Bind code path
|
||||
func (*weChat) Verify(ctx fiber.Ctx, code string) error {
|
||||
return ctx.SendString(code)
|
||||
}
|
||||
@@ -15,6 +15,10 @@ func (f *Middlewares) Auth(ctx fiber.Ctx) error {
|
||||
return ctx.Next()
|
||||
}
|
||||
|
||||
if strings.HasPrefix(ctx.Path(), "/MP_verify_") {
|
||||
return ctx.Next()
|
||||
}
|
||||
|
||||
if strings.HasPrefix(ctx.Path(), "/v1/admin/") {
|
||||
token := ctx.Get("Authorization")
|
||||
if token == "" {
|
||||
|
||||
Reference in New Issue
Block a user