ucp
This commit is contained in:
@@ -6,20 +6,27 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.k6n.net/mats/go-cart-actor/pkg/cart"
|
||||
)
|
||||
|
||||
type CartClient struct {
|
||||
httpClient *http.Client
|
||||
baseUrl string
|
||||
httpClient *http.Client
|
||||
baseUrl string
|
||||
agentProfile string // UCP-Agent profile URI
|
||||
}
|
||||
|
||||
func NewCartClient(baseUrl string) *CartClient {
|
||||
profile := os.Getenv("UCP_AGENT_PROFILE")
|
||||
if profile == "" {
|
||||
profile = "https://checkout.k6n.net/.well-known/ucp"
|
||||
}
|
||||
return &CartClient{
|
||||
httpClient: &http.Client{Timeout: 10 * time.Second},
|
||||
baseUrl: baseUrl,
|
||||
httpClient: &http.Client{Timeout: 10 * time.Second},
|
||||
baseUrl: baseUrl,
|
||||
agentProfile: profile,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +59,7 @@ func (s *CartClient) getCartGrain(ctx context.Context, cartId cart.CartId) (*car
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("UCP-Agent", `profile="`+s.agentProfile+`"`)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user