mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
32 lines
693 B
Go
32 lines
693 B
Go
package netlify
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type OauthTransport struct {
|
|
http.RoundTripper
|
|
AccessToken string
|
|
}
|
|
|
|
func (t *OauthTransport) RoundTrip(req *http.Request) (res *http.Response, err error) {
|
|
req.Header.Set("Authorization", "Bearer "+t.AccessToken)
|
|
return t.RoundTripper.RoundTrip(req)
|
|
}
|
|
|
|
func newOauthClient(ctx context.Context, accessToken string) *http.Client {
|
|
// Update timeout
|
|
var cancel context.CancelFunc
|
|
ctx, cancel = context.WithTimeout(ctx, time.Second*30)
|
|
defer cancel()
|
|
|
|
client := &http.Client{Timeout: 55 * time.Second}
|
|
client.Transport = &OauthTransport{
|
|
AccessToken: accessToken,
|
|
RoundTripper: http.DefaultTransport,
|
|
}
|
|
return client
|
|
}
|