更换 web 框架
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user