chore: refactroing of code

Commenting code for enhancing readability
This commit is contained in:
Jonas Kaninda
2024-11-19 18:18:58 +01:00
parent c54ae4bd34
commit 1c0097d8e4
15 changed files with 117 additions and 86 deletions

View File

@@ -74,7 +74,7 @@ func (proxyRoute ProxyRoute) ProxyHandler() http.HandlerFunc {
r.Host = targetURL.Host
}
backendURL, _ := url.Parse(proxyRoute.destination)
if len(proxyRoute.backends) > 0 {
if len(proxyRoute.backends) != 0 {
// Select the next backend URL
backendURL = getNextBackend(proxyRoute.backends)
}
@@ -87,8 +87,7 @@ func (proxyRoute ProxyRoute) ProxyHandler() http.HandlerFunc {
InsecureSkipVerify: proxyRoute.insecureSkipVerify,
},
}
w.Header().Set("Proxied-By", gatewayName) // Set Server name
w.Header().Del("Server") // Remove the Server header
w.Header().Set("Proxied-By", gatewayName)
// Custom error handler for proxy errors
proxy.ErrorHandler = ProxyErrorHandler
proxy.ServeHTTP(w, r)