1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-24 03:46:37 +02:00
Tony Chen 1afbf70184
examples: add http examples (#822)
* add http examples
2021-04-12 21:37:16 +08:00

30 lines
491 B
Go

package main
import (
"log"
"github.com/gin-gonic/gin"
"github.com/go-kratos/kratos/v2"
"github.com/go-kratos/kratos/v2/transport/http"
)
func main() {
router := gin.Default()
router.GET("/home", func(ctx *gin.Context) {
ctx.String(200, "Hello Gin!")
})
httpSrv := http.NewServer(http.Address(":8000"))
httpSrv.HandlePrefix("/", router)
app := kratos.New(
kratos.Name("gin"),
kratos.Server(
httpSrv,
),
)
if err := app.Run(); err != nil {
log.Println(err)
}
}