尝试登录逻辑
This commit is contained in:
@@ -1,34 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"Crimson-Gatekeeper/internal/common"
|
||||
"Crimson-Gatekeeper/internal/middle"
|
||||
"Crimson-Gatekeeper/internal/query"
|
||||
"Crimson-Gatekeeper/internal/user"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app, close := launchApplication()
|
||||
app, clean := launchApplication()
|
||||
defer clean()
|
||||
err := app.Run(":3333")
|
||||
if err != nil {
|
||||
fmt.Println("应用启动失败")
|
||||
panic(err)
|
||||
}
|
||||
defer close()
|
||||
}
|
||||
|
||||
func launchApplication() (*gin.Engine, func() error) {
|
||||
client, close := common.GetDataBaseClient()
|
||||
db, clean := common.GetDataBaseClient()
|
||||
q := query.Use(db)
|
||||
app := gin.Default()
|
||||
app.GET("/test", func(ctx *gin.Context) {
|
||||
fmt.Println(ctx.Request.URL.Path)
|
||||
ctx.JSON(http.StatusOK, gin.H{
|
||||
"message": "success",
|
||||
})
|
||||
})
|
||||
user.New(client).RegisterRoute(app)
|
||||
return app, close
|
||||
app.Use(middle.ResponsePackageMiddle)
|
||||
user.New(q).RegisterRoute(app)
|
||||
return app, clean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user