安装

go get github.com/ebar-go/ego

主程序

  • main.go

    import (
    "github.com/ebar-go/ego"
    "github.com/gin-gonic/gin"
    "net/http"
    )
    func main() {
      aggregator := ego.NewAggregatorServer()
    
      // 实例化一个http服务
      httpServer := ego.NewHTTPServer(":8080").
          RegisterRouteLoader(func(router *gin.Engine) { // 注册路由
              router.GET("/", func(ctx *gin.Context) {
                  ctx.String(http.StatusOK, "home")
              })
          })
    
      aggregator.WithServer(httpServer)
    
      aggregator.Run()
    }
    

运行

go run main.go

运行后,访问http://localhost:8080/

results matching ""

    No results matching ""