From e80f3068ceef3a2ffd7a0a09f17aa6a58da82fe2 Mon Sep 17 00:00:00 2001 From: Johnny Steenbergen Date: Thu, 4 Jun 2020 11:45:38 -0700 Subject: [PATCH] feat(httpc): extend request with Auth beahvior --- pkg/httpc/req.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/httpc/req.go b/pkg/httpc/req.go index c09503c42e..1f306a80a4 100644 --- a/pkg/httpc/req.go +++ b/pkg/httpc/req.go @@ -38,6 +38,15 @@ func (r *Req) Accept(contentType string) *Req { return r.Header("Accept", contentType) } +// Auth sets the authorization for a request. +func (r *Req) Auth(authFn func(r *http.Request)) *Req { + if r.err != nil { + return r + } + r.authFn = authFn + return r +} + // ContentType sets the Content-Type header to the provided content type on the request. func (r *Req) ContentType(contentType string) *Req { return r.Header("Content-Type", contentType)