diff --git a/client/client.go b/client/client.go index 9d16569..66264de 100644 --- a/client/client.go +++ b/client/client.go @@ -66,6 +66,9 @@ type PortainerClient interface { // Run a function after receiving a response from Portainer AfterResponse(hook func(resp *http.Response) (err error)) + + // Proxy proxies a request to /endpoint/{id}/docker and returns its result + Proxy(endpointId portainer.EndpointID, req *http.Request) (resp *http.Response, err error) } type portainerClientImp struct { @@ -305,6 +308,11 @@ func (n *portainerClientImp) GetStatus() (status portainer.Status, err error) { return } +func (n *portainerClientImp) Proxy(endpointId portainer.EndpointID, req *http.Request) (resp *http.Response, err error) { + resp, err = n.do(fmt.Sprintf("endpoints/%v/docker%s", endpointId, req.RequestURI), req.Method, req.Body, "", req.Header) + return +} + // Create a new client func NewClient(httpClient *http.Client, config Config) PortainerClient { return &portainerClientImp{