Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddRequest ¶
type AddRequest struct {
// A is the first number to add.
A int
// B is the other number to add.
B int
}
AddRequest wrangles the two integers you plan to add together.
type AddResponse ¶
type AddResponse struct {
// Result is the sum you're returning.
Result int
}
AddResponse contains the result from adding two numbers.
type CalculatorService ¶
type CalculatorService interface {
// Add accepts two integers and returns a result w/ their sum.
Add(context.Context, *AddRequest) (*AddResponse, error)
// Sub accepts two integers and returns a result w/ their difference.
Sub(context.Context, *SubRequest) (*SubResponse, error)
}
CalculatorService provides the ability to add and subtract at WEB SCALE!
type CalculatorServiceHandler ¶
type CalculatorServiceHandler struct{}
CalculatorServiceHandler implements all of the "real" functionality for the CalculatorService. The errors that Add/Sub return are completely contrived and don't make sense for real business logic. They are only included to show how you can return specific types of 4XX errors in a readable/maintainable fashion.
func (CalculatorServiceHandler) Add ¶
func (c CalculatorServiceHandler) Add(_ context.Context, req *AddRequest) (*AddResponse, error)
Add accepts two integers and returns a result w/ their sum.
func (CalculatorServiceHandler) Sub ¶
func (c CalculatorServiceHandler) Sub(_ context.Context, req *SubRequest) (*SubResponse, error)
Sub accepts two integers and returns a result w/ their difference.
type SubRequest ¶
type SubRequest struct {
// A is the "minuend" in the subtraction operation.
A int
// B is the "subtrahend" in the subtraction operation.
B int
}
SubRequest wrangles the two integers you plan to subtract.
type SubResponse ¶
type SubResponse struct {
// Result is the difference you're returning.
Result int
}
SubResponse contains the result from subtracting two numbers.