mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Move PrintDebugRequest() and PrintDebugResponse() calls in client to hooks
This commit is contained in:
parent
76d92c5885
commit
5748d862bb
@ -113,8 +113,6 @@ func (n *portainerClientImp) do(uri, method string, request io.Reader, requestTy
|
||||
}
|
||||
}
|
||||
|
||||
util.PrintDebugRequest("Request", req)
|
||||
|
||||
resp, err = n.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return
|
||||
@ -133,8 +131,6 @@ func (n *portainerClientImp) do(uri, method string, request io.Reader, requestTy
|
||||
return
|
||||
}
|
||||
|
||||
util.PrintDebugResponse("Response", resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
|
||||
"github.com/greenled/portainer-stack-utils/util"
|
||||
|
||||
"github.com/greenled/portainer-stack-utils/client"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
@ -24,7 +26,22 @@ func GetClient() (c client.PortainerClient, err error) {
|
||||
|
||||
// Get the default client
|
||||
func GetDefaultClient() (c client.PortainerClient, err error) {
|
||||
return client.NewClient(GetDefaultHttpClient(), GetDefaultClientConfig())
|
||||
c, err = client.NewClient(GetDefaultHttpClient(), GetDefaultClientConfig())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.BeforeRequest(func(req *http.Request) (err error) {
|
||||
util.PrintDebugRequest("Request", req)
|
||||
return
|
||||
})
|
||||
|
||||
c.AfterResponse(func(resp *http.Response) (err error) {
|
||||
util.PrintDebugResponse("Response", resp)
|
||||
return
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Get the default config for a client
|
||||
|
Loading…
Reference in New Issue
Block a user