Enhance reverse proxy transport configuration for improved performance. Updated reverse.go to set a direct transport for the reverse proxy, ensuring more efficient request handling. Modified gateway.go to utilize the direct transport with customized connection settings, optimizing idle connections and timeouts.
Publish telemt-api gateway Docker image / test (push) Failing after 27s
Publish telemt-api gateway Docker image / build-and-push (push) Has been skipped

This commit is contained in:
Denozordec
2026-03-30 00:31:46 +07:00
parent 5934d059a4
commit e1c6b2ab49
3 changed files with 23 additions and 9 deletions
+1
View File
@@ -12,6 +12,7 @@ import (
// (e.g. https://host/api/ + v1 + users → https://host/api/v1/users).
func NewReverseProxy(target *url.URL, stripPrefix, pathPrefix string, setAuth string) *httputil.ReverseProxy {
proxy := httputil.NewSingleHostReverseProxy(target)
proxy.Transport = DirectTransport()
orig := proxy.Director
targetQuery := target.RawQuery
proxy.Director = func(req *http.Request) {
+15
View File
@@ -0,0 +1,15 @@
package proxy
import (
"net/http"
"net/url"
)
// DirectTransport returns a transport that never uses HTTP_PROXY/HTTPS_PROXY.
// Upstream Telemt hosts are usually private or loopback; env proxies break that and
// httptest in CI when runners set HTTP_PROXY.
func DirectTransport() *http.Transport {
t := http.DefaultTransport.(*http.Transport).Clone()
t.Proxy = func(*http.Request) (*url.URL, error) { return nil, nil }
return t
}