feat(client): improved logging, renaming
Some checks failed
Go Tests / go-tests (push) Failing after 1m4s
Some checks failed
Go Tests / go-tests (push) Failing after 1m4s
This commit is contained in:
parent
044f1b04b8
commit
017d56687e
3 changed files with 95 additions and 30 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"log"
|
||||
"net/http"
|
||||
|
|
@ -51,26 +52,35 @@ func (e *EdgeConnect) NewAppInstance(ctx context.Context, input NewAppInstanceIn
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
log.Printf("failed received non 200 status code %v\n", resp.Status)
|
||||
bytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Printf("err while io.ReadAll: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Body %v\n", string(bytes))
|
||||
|
||||
log.Printf("status code %v\n", resp.Status)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *EdgeConnect) NewApp(ctx context.Context, input NewAppInput) error {
|
||||
token, err := e.RetrieveToken(ctx)
|
||||
if err != nil {
|
||||
log.Printf("err while RetrieveToken: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
json_data, err := json.Marshal(input)
|
||||
if err != nil {
|
||||
log.Printf("err while Marshal: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
request, err := http.NewRequestWithContext(ctx, "POST", e.BaseURL+"/api/v1/auth/ctrl/CreateApp", bytes.NewBuffer(json_data))
|
||||
if err != nil {
|
||||
log.Printf("err while NewRequestWithContext: %v\n", err)
|
||||
return err
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
|
|
@ -78,10 +88,21 @@ func (e *EdgeConnect) NewApp(ctx context.Context, input NewAppInput) error {
|
|||
|
||||
resp, err := e.HttpClient.Do(request)
|
||||
if err != nil {
|
||||
log.Printf("err while HttpClient.Do: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
log.Printf("status code %v\n", resp.Status)
|
||||
bytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Printf("err while io.ReadAll: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Body %v\n", string(bytes))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue