feat: complete auth
This commit is contained in:
19
main.go
19
main.go
@@ -1,11 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.ipao.vip/rogeecn/mp-qvyun/pkg/middlewares/fiberv3"
|
||||
"git.ipao.vip/rogeecn/mp-qvyun/pkg/wechat"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
func main() {
|
||||
wechatClient := wechat.New(
|
||||
wechat.WithAppID(WechatAppID),
|
||||
@@ -14,15 +19,17 @@ func main() {
|
||||
wechat.WithToken(WechatToken),
|
||||
)
|
||||
|
||||
wechatMiddlewares := fiberv3.Init(wechatClient)
|
||||
|
||||
// create a new fiber server
|
||||
app := fiber.New()
|
||||
app.Use(LogAll)
|
||||
app.Use(wechatMiddlewares.Verify)
|
||||
app.Use(wechatMiddlewares.AuthUserInfo)
|
||||
app.Use(wechatMiddlewares.SilentAuth)
|
||||
|
||||
app.Use(VerifyWechatServer(wechatClient))
|
||||
|
||||
app.Get("/videos", func(c fiber.Ctx) error {
|
||||
log.Infof("GET: %+v", c.Queries())
|
||||
log.Infof("POST: %s", c.Body())
|
||||
return c.SendString(c.Query("echostr", "Error"))
|
||||
app.Get("/", func(c fiber.Ctx) error {
|
||||
return c.SendString("Hello World")
|
||||
})
|
||||
|
||||
// listen on port 3000
|
||||
|
||||
Reference in New Issue
Block a user