Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultProtobufHTTPClient = CreateProtobufHTTPClient(nil, nil, nil)
DefaultProtobufHTTPClient uses default http Client, error mapper and marshaller
Functions ¶
func MarshalMessageBody ¶
MarshalMessageBody convenience method to marshal different interfaces into JSON
func Obfuscate ¶
Obfuscate is a helper function to obfuscate a string, used mostly to hide passwords, etc
func SplitMethodAndPackage ¶
SplitMethodAndPackage is a helper method to split gRPC `package.service/method`
Types ¶
type ErrorMapper ¶ added in v1.0.2
ErrorMapper is a map function that maps HTTP Status Code into its gRPC counter part.
type MDTraceCarrier ¶
MDTraceCarrier is an implementation for Tracing carrier, it will hold traceID, etc
func (MDTraceCarrier) ForeachKey ¶
func (md MDTraceCarrier) ForeachKey(handler func(key, value string) error) error
ForeachKey part of the Carrier interface
func (MDTraceCarrier) Set ¶
func (md MDTraceCarrier) Set(key, value string)
Set part of the Carrier interface
type ProtobufHTTPClient ¶ added in v1.0.2
type ProtobufHTTPClient interface { // Example: // var response *pbpkg.ResponseMessage // var request = &pbpkg.RequestMessage{Name: "test"} // err := Do(ctx, http.MethodPost, "http://host/path", request, &response) // // Error returned will be of type `(*status.Status).Err()` meaning it will be a gRPC type error. // // Note: // you can pass `nil` as the last parameter if you don't want to unmarshal HTTP response body. // or you know it's going to be empty == EOF // err := Do(ctx, http.MethodPost, "http://host/path", request, nil) Do(ctx context.Context, method, url string, in proto.Message, out interface{}) error }
ProtobufHTTPClient is a helper util in situations where you want to call a REST API, but you have all the definitions as Protobuf.
func CreateProtobufHTTPClient ¶ added in v1.0.2
func CreateProtobufHTTPClient(client *http.Client, errorMapper ErrorMapper, marshaller runtime.Marshaler) ProtobufHTTPClient
CreateProtobufHTTPClient Creates a custom Protobuf aware HTTP client