mirror of https://github.com/portainer/portainer
feat(api): remove any version api before proxying request (#1806)
parent
2a9ba1f9a2
commit
4f0e752d00
|
@ -5,12 +5,15 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/portainer/portainer"
|
||||
"github.com/portainer/portainer/http/security"
|
||||
)
|
||||
|
||||
var apiVersionRe = regexp.MustCompile(`(/v[0-9]\.[0-9]*)?`)
|
||||
|
||||
type (
|
||||
proxyTransport struct {
|
||||
dockerTransport *http.Transport
|
||||
|
@ -55,7 +58,8 @@ func (p *proxyTransport) executeDockerRequest(request *http.Request) (*http.Resp
|
|||
}
|
||||
|
||||
func (p *proxyTransport) proxyDockerRequest(request *http.Request) (*http.Response, error) {
|
||||
path := request.URL.Path
|
||||
path := apiVersionRe.ReplaceAllString(request.URL.Path, "")
|
||||
request.URL.Path = path
|
||||
|
||||
switch {
|
||||
case strings.HasPrefix(path, "/configs"):
|
||||
|
|
Loading…
Reference in New Issue