mirror of
https://github.com/go-micro/go-micro.git
synced 2025-01-29 18:04:17 +02:00
34 lines
731 B
Go
34 lines
731 B
Go
package main
|
|
|
|
import (
|
|
"github.com/micro/go-micro/v2/util/log"
|
|
|
|
"github.com/micro/go-micro/examples/template/api/client"
|
|
"github.com/micro/go-micro/examples/template/api/handler"
|
|
"github.com/micro/go-micro/v2"
|
|
|
|
example "github.com/micro/go-micro/examples/template/api/proto/example"
|
|
)
|
|
|
|
func main() {
|
|
// New Service
|
|
service := micro.NewService(
|
|
micro.Name("go.micro.api.template"),
|
|
micro.Version("latest"),
|
|
)
|
|
|
|
// Register Handler
|
|
example.RegisterExampleHandler(service.Server(), new(handler.Example))
|
|
|
|
// Initialise service
|
|
service.Init(
|
|
// create wrap for the Example srv client
|
|
micro.WrapHandler(client.ExampleWrapper(service)),
|
|
)
|
|
|
|
// Run service
|
|
if err := service.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|