mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 03:05:14 +00:00
25 lines
501 B
Go
25 lines
501 B
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
pb "example/proto"
|
|
)
|
|
|
|
type Example struct{}
|
|
|
|
// Call is a single request handler called via client.Call or the generated client code
|
|
func (e *Example) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
|
|
fmt.Println("Received Example.Call request")
|
|
rsp.Msg = "Hello " + req.Name
|
|
if req.Number > 0 {
|
|
rsp.Msg = fmt.Sprintf("%s %d", rsp.Msg, req.Number)
|
|
}
|
|
if req.Caps {
|
|
rsp.Msg = strings.ToUpper(rsp.Msg)
|
|
}
|
|
return nil
|
|
}
|