diff --git a/impl_request.go b/impl_request.go index d0d70238..6119bef8 100644 --- a/impl_request.go +++ b/impl_request.go @@ -129,6 +129,11 @@ func (r *Lark) parseRawHttpRequest(ctx context.Context, req *RawRequestReq) (*ra if req.MethodOption.timeout > 0 { rawHttpReq.Timeout = req.MethodOption.timeout } + if len(req.MethodOption.headers) > 0 { + for k, v := range req.MethodOption.headers { + rawHttpReq.Headers[k] = v + } + } // 1 headers if err := rawHttpReq.parseHeader(ctx, r, req); err != nil { diff --git a/lark.go b/lark.go index 80d79d87..b854b7e9 100644 --- a/lark.go +++ b/lark.go @@ -174,10 +174,18 @@ func WithRequestTimeout(timeout time.Duration) MethodOptionFunc { } } +// WithRequestHeaders set request headers +func WithRequestHeaders(headers map[string]string) MethodOptionFunc { + return func(option *MethodOption) { + option.headers = headers + } +} + // MethodOption method option type MethodOption struct { userAccessToken string timeout time.Duration + headers map[string]string } func newMethodOption(options []MethodOptionFunc) *MethodOption {