Documentation ¶
Index ¶
- type AddRequest
- type AddResponse
- type CalculatorService
- type CalculatorServiceHandler
- func (svc CalculatorServiceHandler) Add(_ context.Context, req *AddRequest) (*AddResponse, error)
- func (svc CalculatorServiceHandler) Double(_ context.Context, req *DoubleRequest) (*DoubleResponse, error)
- func (svc CalculatorServiceHandler) Mul(_ context.Context, req *MulRequest) (*MulResponse, error)
- func (svc CalculatorServiceHandler) Sub(_ context.Context, req *SubRequest) (*SubResponse, error)
- type DoubleRequest
- type DoubleResponse
- type MulRequest
- type MulResponse
- type SubRequest
- type SubResponse
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 { // Value contains the resulting sum. Value int }
AddResponse represents the result of an Add() operation.
type CalculatorService ¶
type CalculatorService interface { // Add calculates and returns the sum of two numbers. // // HTTP 200 // GET /add/{A}/{B} Add(context.Context, *AddRequest) (*AddResponse, error) // Sub calculates and returns the difference between two numbers. // // HTTP 200 // GET /sub/{A}/{B} Sub(context.Context, *SubRequest) (*SubResponse, error) // Mul calculates and returns the product of two numbers. // // HTTP 200 // GET /multiply/{A}/{B} Mul(context.Context, *MulRequest) (*MulResponse, error) // Double multiplies the value by 2 // // HTTP 200 // POST /double/{Value} // ON CalculatorService.Mul Double(context.Context, *DoubleRequest) (*DoubleResponse, error) }
CalculatorService provides the ability to perform basic arithmetic on two numbers.
type CalculatorServiceHandler ¶
type CalculatorServiceHandler struct{}
func (CalculatorServiceHandler) Add ¶
func (svc CalculatorServiceHandler) Add(_ context.Context, req *AddRequest) (*AddResponse, error)
func (CalculatorServiceHandler) Double ¶
func (svc CalculatorServiceHandler) Double(_ context.Context, req *DoubleRequest) (*DoubleResponse, error)
func (CalculatorServiceHandler) Mul ¶
func (svc CalculatorServiceHandler) Mul(_ context.Context, req *MulRequest) (*MulResponse, error)
func (CalculatorServiceHandler) Sub ¶
func (svc CalculatorServiceHandler) Sub(_ context.Context, req *SubRequest) (*SubResponse, error)
type DoubleRequest ¶
type DoubleRequest struct { // Value is the number to multiply by 2. Value int }
DoubleRequest contains the number we're multiplying by 2 in a Double() operation.
type DoubleResponse ¶
type DoubleResponse struct { // Value contains the resulting product. Value int }
DoubleResponse represents the result of a Mul() operation.
type MulRequest ¶
type MulRequest struct { // A is the first factor to multiply. A int // B is the other factor to multiply. B int }
MulRequest contains the two numbers whose product you're calculating in Mul().
type MulResponse ¶
type MulResponse struct { // Value contains the resulting product. Value int }
MulResponse represents the result of a Mul() operation.
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 contains the two numbers whose difference you're calculating in Sub().
type SubResponse ¶
type SubResponse struct { // Value contains the resulting difference. Value int }
SubResponse represents the result of an Add() operation.
Click to show internal directories.
Click to hide internal directories.