40 lines
834 B
Go
40 lines
834 B
Go
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),
|
|
wechat.WithAppSecret(WechatAppSecret),
|
|
wechat.WithAESKey(WechatAesKey),
|
|
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.Get("/", func(c fiber.Ctx) error {
|
|
return c.SendString("Hello World")
|
|
})
|
|
|
|
// listen on port 3000
|
|
if err := app.Listen(":3000"); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|