Files
Crimson-Gatekeeper/srv/cmd/gatekeeper/main.go
2026-01-14 19:04:01 +08:00

35 lines
636 B
Go

package main
import (
"fmt"
"net/http"
"Crimson-Gatekeeper/internal/common"
"Crimson-Gatekeeper/internal/user"
"github.com/gin-gonic/gin"
)
func main() {
app, close := launchApplication()
err := app.Run(":3333")
if err != nil {
fmt.Println("应用启动失败")
panic(err)
}
defer close()
}
func launchApplication() (*gin.Engine, func() error) {
client, close := common.GetDataBaseClient()
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
}