go-template/app/api/example_api/example_api.go
icechen cdd70a9ae3
Some checks failed
continuous-integration/drone/push Build is failing
test
2021-12-31 00:43:53 +08:00

25 lines
554 B
Go

package main
import (
"context"
"git.icechen.cn/${REPO_NAME}/${REPO_NAME}/pkg/proto/example_service"
"git.icechen.cn/${REPO_NAME}/${REPO_NAME}/pkg/rpc"
"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)
}
}