You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
490 B
29 lines
490 B
4 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"github.com/go-kratos/kratos/v2"
|
||
4 years ago
|
"github.com/go-kratos/kratos/v2/transport/http"
|
||
4 years ago
|
)
|
||
|
|
||
|
func main() {
|
||
|
router := gin.Default()
|
||
|
router.GET("/home", func(ctx *gin.Context) {
|
||
|
ctx.String(200, "Hello Gin!")
|
||
|
})
|
||
4 years ago
|
httpSrv := http.NewServer(http.Address(":8000"))
|
||
4 years ago
|
httpSrv.HandlePrefix("/", router)
|
||
|
|
||
|
app := kratos.New(
|
||
|
kratos.Name("gin"),
|
||
|
kratos.Server(
|
||
|
httpSrv,
|
||
|
),
|
||
|
)
|
||
|
if err := app.Run(); err != nil {
|
||
|
log.Println(err)
|
||
|
}
|
||
|
}
|