2021-03-05 23:49:25 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/go-kratos/kratos/v2"
|
2021-03-15 17:10:32 +08:00
|
|
|
"github.com/go-kratos/kratos/v2/transport/http"
|
2021-03-05 23:49:25 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
router := gin.Default()
|
|
|
|
router.GET("/home", func(ctx *gin.Context) {
|
|
|
|
ctx.String(200, "Hello Gin!")
|
|
|
|
})
|
2021-04-12 21:37:16 +08:00
|
|
|
|
2021-03-15 17:10:32 +08:00
|
|
|
httpSrv := http.NewServer(http.Address(":8000"))
|
2021-03-05 23:49:25 +08:00
|
|
|
httpSrv.HandlePrefix("/", router)
|
|
|
|
|
|
|
|
app := kratos.New(
|
|
|
|
kratos.Name("gin"),
|
|
|
|
kratos.Server(
|
|
|
|
httpSrv,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
if err := app.Run(); err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
}
|