Fix workflow apiserver proxy (#363)
This commit is contained in:
committed by
Soam Vasani
parent
0537c4b805
commit
59c18693fa
@@ -2,25 +2,27 @@ package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (api *API) WorkflowApiProxy(w http.ResponseWriter, r *http.Request) {
|
||||
u := api.storageServiceUrl
|
||||
func (api *API) WorkflowApiserverProxy(w http.ResponseWriter, r *http.Request) {
|
||||
u := api.workflowApiUrl
|
||||
ssUrl, err := url.Parse(u)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("Error parsing url %v: %v", u, err)
|
||||
http.Error(w, msg, 500)
|
||||
return
|
||||
}
|
||||
|
||||
vars := mux.Vars(r)
|
||||
path := fmt.Sprintf("/%s", vars["path"])
|
||||
director := func(req *http.Request) {
|
||||
req.URL.Scheme = ssUrl.Scheme
|
||||
req.URL.Host = ssUrl.Host
|
||||
req.URL.Path = strings.TrimPrefix(ssUrl.Path, "/proxy/workflow")
|
||||
req.URL.RawQuery = ssUrl.RawQuery
|
||||
req.URL.Path = path
|
||||
}
|
||||
proxy := &httputil.ReverseProxy{
|
||||
Director: director,
|
||||
|
||||
Reference in New Issue
Block a user