26 lines
565 B
Go
26 lines
565 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"git.icechen.cn/pkg/go-template/pkg/proto/example_service"
|
|
"git.icechen.cn/pkg/go-template/pkg/rpc"
|
|
"github.com/gofiber/fiber/v2"
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
|
)
|
|
|
|
func main() {
|
|
app := fiber.New()
|
|
app.Get("/test", func(c *fiber.Ctx) error {
|
|
userInfo, err := example_service.NewUserClient(rpc.GetServiceConn("example_service")).SayHello(context.TODO(), &emptypb.Empty{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(userInfo.Name)
|
|
})
|
|
err := app.Listen(":8080")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|