-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (38 loc) · 1.08 KB
/
main.go
File metadata and controls
42 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"bookManagerSystem/api/controller"
_ "bookManagerSystem/docs"
"bookManagerSystem/log"
"bookManagerSystem/routers"
"bookManagerSystem/untils"
"fmt"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
echoSwagger "github.com/swaggo/echo-swagger"
)
// @title Swagger Example API
// @host petstore.swagger.io
// @BasePath /v1
func main() {
e := echo.New()
e.Static("/static", "static")
e.Use(middleware.Recover())
e.Any("/*", echoSwagger.WrapHandler)
//自定义中间件
//e.Use(filter.CustomFilter)
e.POST("/v1/login", controller.HandleLoginController)
//初始化连接数据库实例
go controller.DriverMySQL()
go controller.ConnectRedis()
go controller.ConnectMysqlWithGorm()
go controller.InitEMailPool()
go controller.TimerSendEmail()
go log.Init()
r := e.Group("/v1")
r.Use(middleware.JWTWithConfig(middleware.JWTConfig{SigningMethod: "HS512", SigningKey: []byte("secret")}))
routers.InitRouter(r)
//初始化路由
//开启服务
port := untils.ReadCon("base", "port")
e.Logger.Fatal(e.Start(fmt.Sprintf(":%s", port)))
}