快速开始
创建项目
import (
"github.com/gin-gonic/gin"
"github.com/gotomicro/ego/core/elog"
"github.com/gotomicro/ego/server/egin"
)
func main() {
if err := ego.New().Serve(func() *egin.Component {
server := egin.Load("server.http").Build()
server.GET("/hello", func(ctx *gin.Context) {
ctx.JSON(200, "Hello Ego")
return
}()).Run(); err != nil {
elog.Panic("startup", elog.Any("err", err))
}
}
- 在项目中增加config.toml配置文件,内容如下
[server.http]
port = 9001
host = "0.0.0.0"