-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (34 loc) · 871 Bytes
/
main.go
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
package main
import (
"gin-demo/controller"
_ "gin-demo/docs"
"gin-demo/middleware"
"gin-demo/tools"
_ "gin-demo/tools"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"net/http"
)
// @title swageer demo
// @version 3.0
// @description golang gin web swager demo
// @termsOfService http://127.0.0.1:8080
func main() {
// init
tools.InitConfig()
tools.InitLog()
tools.InitOrmDB()
tools.Migrate()
tools.InitMysql()
tools.InitRedisCli()
r := gin.Default()
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
r.Use(middleware.CatchError(http.StatusInternalServerError))
r.POST("/login", controller.Login)
r.Use(middleware.AuthMiddleware())
r.POST("/user", controller.CreateUser)
r.GET("/user", controller.GetUserInfo)
r.PUT("/user", controller.UpdateUserInfo)
r.Run()
}