v1.2.1
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/rudecs/decort-sdk/config"
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/config"
|
||||
)
|
||||
|
||||
func NewHttpClient(cfg config.Config) *http.Client {
|
||||
|
||||
@@ -3,9 +3,10 @@ package client
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/rudecs/decort-sdk/config"
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/config"
|
||||
)
|
||||
|
||||
// NewLegacyHttpClient creates legacy HTTP Client
|
||||
@@ -20,8 +21,8 @@ func NewLegacyHttpClient(cfg config.LegacyConfig) *http.Client {
|
||||
return &http.Client{
|
||||
Transport: &transportLegacy{
|
||||
base: transCfg,
|
||||
username: cfg.Username,
|
||||
password: cfg.Password,
|
||||
username: url.QueryEscape(cfg.Username),
|
||||
password: url.QueryEscape(cfg.Password),
|
||||
retries: cfg.Retries,
|
||||
token: cfg.Token,
|
||||
decortURL: cfg.DecortURL,
|
||||
|
||||
@@ -41,10 +41,12 @@ func (t *transportLegacy) RoundTrip(request *http.Request) (*http.Response, erro
|
||||
t.token = token
|
||||
}
|
||||
|
||||
tokenValue := fmt.Sprintf("authkey=%s", t.token)
|
||||
tokenValue := fmt.Sprintf("&authkey=%s", t.token)
|
||||
tokenReader := strings.NewReader(tokenValue)
|
||||
|
||||
req, _ := http.NewRequestWithContext(request.Context(), request.Method, request.URL.String(), tokenReader)
|
||||
newBody := io.MultiReader(request.Body, tokenReader)
|
||||
|
||||
req, _ := http.NewRequestWithContext(request.Context(), request.Method, request.URL.String(), newBody)
|
||||
|
||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
18
internal/serialization/serialize.go
Normal file
18
internal/serialization/serialize.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package serialization
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type Writable interface {
|
||||
WriteToFile(string) error
|
||||
}
|
||||
|
||||
type Serialized []byte
|
||||
|
||||
// WriteToFile writes serialized data to specified file.
|
||||
//
|
||||
// Make sure to use .json extension for best compatibility.
|
||||
func (s Serialized) WriteToFile(path string) error {
|
||||
return os.WriteFile(path, s, 0600)
|
||||
}
|
||||
Reference in New Issue
Block a user