Files
Crimson-Gatekeeper/srv/cmd/gatekeeper/main.go

35 lines
636 B
Go
Raw Normal View History

2026-01-13 00:08:49 +08:00
package main
import (
2026-01-13 23:15:16 +08:00
"fmt"
2026-01-13 00:08:49 +08:00
"net/http"
2026-01-14 19:04:01 +08:00
"Crimson-Gatekeeper/internal/common"
"Crimson-Gatekeeper/internal/user"
2026-01-13 23:15:16 +08:00
"github.com/gin-gonic/gin"
2026-01-13 00:08:49 +08:00
)
func main() {
2026-01-14 19:04:01 +08:00
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()
2026-01-13 23:15:16 +08:00
app := gin.Default()
app.GET("/test", func(ctx *gin.Context) {
fmt.Println(ctx.Request.URL.Path)
ctx.JSON(http.StatusOK, gin.H{
"message": "success",
})
2026-01-13 00:08:49 +08:00
})
2026-01-14 19:04:01 +08:00
user.New(client).RegisterRoute(app)
return app, close
2026-01-13 00:08:49 +08:00
}