Created
November 6, 2020 11:51
-
-
Save asim/64e0befe4dfc02a075bd4297037c91c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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