Skip to content

Instantly share code, notes, and snippets.

@asim
Created November 6, 2020 11:51
Show Gist options
  • Save asim/64e0befe4dfc02a075bd4297037c91c4 to your computer and use it in GitHub Desktop.
Save asim/64e0befe4dfc02a075bd4297037c91c4 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
"github.com/micro/services/helloworld/handler"
helloworld "github.com/micro/services/helloworld/proto"
)
type Helloworld struct{}
// Call is a single request handler called via client.Call or the generated client code
func (e *Helloworld) Call(ctx context.Context, req *helloworld.Request, rsp *helloworld.Response) error {
logger.Info("Received Helloworld.Call request")
rsp.Msg = "Hello " + req.Name
return nil
}
func main() {
// Create service
srv := service.New(
service.Name("helloworld"),
)
// Register Handler
srv.Handle(new(Helloworld))
// Run the service
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment