mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add function in Portainer client to proxy a request to Docker API
This commit is contained in:
parent
0be0262fcb
commit
6c45c77466
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user