An API that doesn’t accept any request data is not very useful! Let’s fix that.
First, add a new Request
type with a Name
field:
type Request struct {
Name string
}
Then, change the Greet
function to accept a *Request
as its second parameter:
func Greet(ctx context.Context, req *Request) (*Response, error) {
return &Response{Message: "Hello, " + req.Name + "!"}, nil
}
Try changing Hello
to another greeting and press Deploy to see your changes.