更换 web 框架

This commit is contained in:
des
2026-01-13 23:15:16 +08:00
parent a289a90676
commit c0054a9608
4 changed files with 116 additions and 20 deletions

View File

@@ -1,21 +1,25 @@
package main
import (
"fmt"
"net/http"
"github.com/labstack/echo"
"Crimson-Gatekeeper/internal/common"
"github.com/gin-gonic/gin"
)
func main() {
client, close := common.GetDataBaseClient()
defer close()
app := echo.New()
app.GET("/", func(ctx echo.Context) error {
return ctx.String(http.StatusOK, "Hello, World!")
//client, close := common.GetDataBaseClient()
//defer close()
app := gin.Default()
app.GET("/test", func(ctx *gin.Context) {
fmt.Println(ctx.Request.URL.Path)
ctx.JSON(http.StatusOK, gin.H{
"message": "success",
})
})
app.Logger.Fatal(app.Start(":8443"))
defer app.Close()
err := app.Run(":8443")
if err != nil {
fmt.Println("应用启动失败")
panic(err)
}
}