Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11900eeecd | |||
| 4f9ef33ab1 | |||
| be77803d96 |
@@ -4,10 +4,11 @@ import (
|
||||
"fmt"
|
||||
|
||||
basket "git.ego.freeddns.org/egommerce/api-entities/basket/dto"
|
||||
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
|
||||
)
|
||||
|
||||
func NewBasketAPI() *BasketAPI {
|
||||
return &BasketAPI{NewHttpClient()}
|
||||
return &BasketAPI{NewHttpClient(cnf.GetEnv("API_REST_BASKET", "basket-svc"))}
|
||||
}
|
||||
|
||||
type BasketAPI struct {
|
||||
|
||||
@@ -2,16 +2,18 @@ package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type HttpClient struct {
|
||||
baseURL string
|
||||
userAgent string
|
||||
}
|
||||
|
||||
func NewHttpClient() *HttpClient {
|
||||
return &HttpClient{userAgent: "internal-http-client"}
|
||||
func NewHttpClient(apiURL string) *HttpClient {
|
||||
return &HttpClient{baseURL: apiURL, userAgent: "internal-http-client"}
|
||||
}
|
||||
|
||||
func (c *HttpClient) SendGet(api, url string, data, out any) error {
|
||||
@@ -46,7 +48,13 @@ func (c *HttpClient) SendPost(api, url string, data, out any) (any, error) {
|
||||
|
||||
func (c *HttpClient) sendRequest(api, url, method string, data any) (*http.Response, error) {
|
||||
apiUrl := api + url // FIXME
|
||||
client := &http.Client{}
|
||||
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // FIXME
|
||||
}
|
||||
|
||||
// Create an HTTP client with the custom transport
|
||||
client := &http.Client{Transport: tr} // FIXME
|
||||
|
||||
json, err := json.Marshal(&data)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
identity "git.ego.freeddns.org/egommerce/api-entities/identity/dto"
|
||||
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
|
||||
)
|
||||
|
||||
type IdentityAPI struct {
|
||||
@@ -9,7 +10,7 @@ type IdentityAPI struct {
|
||||
}
|
||||
|
||||
func NewIdentityAPI() *IdentityAPI {
|
||||
return &IdentityAPI{NewHttpClient()}
|
||||
return &IdentityAPI{NewHttpClient(cnf.GetEnv("API_REST_IDENTITY", "identity-svc"))}
|
||||
}
|
||||
|
||||
func (a *IdentityAPI) CheckAccess(url, srv string) (*identity.CheckAccessResponseDTO, error) {
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"fmt"
|
||||
|
||||
pricing "git.ego.freeddns.org/egommerce/api-entities/pricing/dto"
|
||||
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
|
||||
)
|
||||
|
||||
func NewPricingAPI() *PricingAPI {
|
||||
return &PricingAPI{NewHttpClient()}
|
||||
return &PricingAPI{NewHttpClient(cnf.GetEnv("API_REST_PRICING", "pricing-svc"))}
|
||||
}
|
||||
|
||||
type PricingAPI struct {
|
||||
|
||||
Reference in New Issue
Block a user