Documentation
¶
Overview ¶
Package remoteaddr gets the gRPC client's remote address.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotAvailable is returned when the remote client address is not available ErrNotAvailable = errors.New("remote address is not available") )
Functions ¶
func GetFromContext ¶
GetFromContext returns the remote address of the client calling the method, for both unary and streaming method, in a gRPC call context. ErrNotAvailable is returned if remote address is not available.
Example ¶
ExampleGetFromContext show how to get the remote address from client
package main import ( "context" "fmt" "github.com/jucrouzet/grpcutils/pkg/remoteaddr" ) // ExampleGetFromContext show how to get the remote address from client func main() { addr, err := remoteaddr.GetFromContext(ctx) if err != nil { // There was an error while getting the remote address } // addr is now client's remote address fmt.Println(addr) } var ctx context.Context
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.