1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-23 20:32:32 +02:00

43 lines
845 B
Go
Raw Normal View History

2020-12-26 15:17:20 +00:00
package main
import (
"log"
"time"
"context"
2021-01-20 21:28:48 +00:00
hello "github.com/asim/go-micro/examples/v3/greeter/srv/proto/hello"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/transport"
2020-12-26 15:17:20 +00:00
)
type Say struct{}
func (s *Say) Hello(ctx context.Context, req *hello.Request, rsp *hello.Response) error {
rsp.Msg = "Hello " + req.Name
return nil
}
func main() {
service := micro.NewService(
micro.Name("go.micro.srv.greeter"),
micro.RegisterTTL(time.Second*30),
micro.RegisterInterval(time.Second*10),
// setup a new transport with secure option
micro.Transport(
// create new transport
2021-01-20 21:28:48 +00:00
transport.NewHTTPTransport(
2020-12-26 15:17:20 +00:00
// set to automatically secure
transport.Secure(true),
),
),
)
service.Init()
hello.RegisterSayHandler(service.Server(), new(Say))
if err := service.Run(); err != nil {
log.Fatal(err)
}
}