feat(httpc): extend request with Auth beahvior

pull/18370/head
Johnny Steenbergen 2020-06-04 11:45:38 -07:00 committed by Johnny Steenbergen
parent 9bf1cc78d0
commit e80f3068ce
1 changed files with 9 additions and 0 deletions

View File

@ -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)