From 618421de05b9820516331431622deaab3b0fa876 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 9 Apr 2021 23:08:54 +0300 Subject: [PATCH] client: allow to set content-type for call Signed-off-by: Vasiliy Tolstov --- client/options.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/client/options.go b/client/options.go index 3d046bd8..8dccd296 100644 --- a/client/options.go +++ b/client/options.go @@ -80,6 +80,8 @@ type CallOptions struct { Backoff BackoffFunc // Network name Network string + // Content-Type + ContentType string // CallWrappers call wrappers CallWrappers []CallWrapper // SelectOptions selector options @@ -382,6 +384,13 @@ func PublishContext(ctx context.Context) PublishOption { } } +// WithContentType specifies call content type +func WithContentType(ct string) CallOption { + return func(o *CallOptions) { + o.ContentType = ct + } +} + // WithAddress sets the remote addresses to use rather than using service discovery func WithAddress(a ...string) CallOption { return func(o *CallOptions) { @@ -486,16 +495,16 @@ func WithMessageContentType(ct string) MessageOption { } } -// WithContentType specifies request content type -func WithContentType(ct string) RequestOption { +// StreamingRequest specifies that request is streaming +func StreamingRequest(b bool) RequestOption { + return func(o *RequestOptions) { + o.Stream = b + } +} + +// RequestContentType specifies request content type +func RequestContentType(ct string) RequestOption { return func(o *RequestOptions) { o.ContentType = ct } } - -// StreamingRequest specifies that request is streaming -func StreamingRequest() RequestOption { - return func(o *RequestOptions) { - o.Stream = true - } -}