Skip to content

Commit

Permalink
Add uhttp.WithBearerToken method
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusGoldschmidt committed Dec 20, 2024
1 parent e7a5caf commit 91fd2f3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/uhttp/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
applicationFormUrlencoded = "application/x-www-form-urlencoded"
applicationVndApiJSON = "application/vnd.api+json"
acceptHeader = "Accept"
authorizationHeader = "Authorization"
)

const maxBodySize = 4096
Expand Down Expand Up @@ -464,6 +465,10 @@ func WithAccept(value string) RequestOption {
return WithHeader(acceptHeader, value)
}

func WithBearerToken(token string) RequestOption {
return WithHeader(authorizationHeader, fmt.Sprintf("Bearer %s", token))
}

func (c *BaseHttpClient) NewRequest(ctx context.Context, method string, url *url.URL, options ...RequestOption) (*http.Request, error) {
var buffer io.ReadWriter
var headers map[string]string = make(map[string]string)
Expand Down

0 comments on commit 91fd2f3

Please sign in to comment.