@@ -42,40 +42,42 @@ func RequestHandler(c *gin.Context) {
42
42
c .Request .Header .Set ("Origin" , ORIGIN )
43
43
c .Request .Header .Set ("Accept-Encoding" , "*" )
44
44
defer c .Request .Body .Close ()
45
+
45
46
if c .IsWebsocket () {
47
+
46
48
proxy .ServeHTTP (c .Writer , c .Request )
47
- return
48
- }
49
49
50
- tr := & http.Transport {
51
- TLSClientConfig : tlsConf , // TODO: add a check for PROD / DEV mode
52
- }
50
+ } else {
53
51
54
- cr := func ( req * http.Request , via [] * http. Request ) error {
55
- return http . ErrUseLastResponse
56
- }
52
+ tr := & http.Transport {
53
+ TLSClientConfig : tlsConf , // TODO: add a check for PROD / DEV mode
54
+ }
57
55
58
- httpClient := http.Client {Transport : tr , CheckRedirect : cr }
56
+ cr := func (req * http.Request , via []* http.Request ) error {
57
+ return http .ErrUseLastResponse
58
+ }
59
59
60
- c .Request .RequestURI = ""
61
- resp , err := httpClient .Do (c .Request )
62
- if err != nil {
63
- log .Println ("Failed to initiate call to kube api server: " , err .Error ())
64
- }
60
+ httpClient := http.Client {Transport : tr , CheckRedirect : cr }
65
61
66
- bodyBytes , err := io .ReadAll (resp .Body )
62
+ c .Request .RequestURI = ""
63
+ resp , err := httpClient .Do (c .Request )
64
+ if err != nil {
65
+ log .Println ("Failed to initiate call to kube api server: " , err .Error ())
66
+ }
67
67
68
- if err != nil {
69
- log .Println ("Failed to read response body: " , err .Error ())
70
- }
68
+ bodyBytes , err := io .ReadAll (resp .Body )
71
69
72
- defer resp .Body .Close ()
73
- filteredJson := util .FilterResponseQuery (bodyBytes , c .Request .URL .Query ())
70
+ if err != nil {
71
+ log .Println ("Failed to read response body: " , err .Error ())
72
+ }
74
73
75
- if err != nil {
76
- log .Println ("Unable to transform response body to json) " , err .Error ())
77
- }
74
+ defer resp .Body .Close ()
75
+ filteredJson := util .FilterResponseQuery (bodyBytes , c .Request .URL .Query ())
78
76
79
- c .JSON (http .StatusOK , filteredJson )
77
+ if err != nil {
78
+ log .Println ("Unable to transform response body to json) " , err .Error ())
79
+ }
80
80
81
+ c .JSON (http .StatusOK , filteredJson )
82
+ }
81
83
}
0 commit comments