MCPcopy Index your code
hub / github.com/labstack/echo / createSimpleProxyServer

Function createSimpleProxyServer

middleware/proxy_test.go:963–996  ·  view source on GitHub ↗
(t *testing.T, srv *httptest.Server, serveTLS bool, toTLS bool)

Source from the content-addressed store, hash-verified

961}
962
963func createSimpleProxyServer(t *testing.T, srv *httptest.Server, serveTLS bool, toTLS bool) *httptest.Server {
964 e := echo.New()
965
966 if toTLS {
967 // proxy to tls target
968 tgtURL, _ := url.Parse(srv.URL)
969 tgtURL.Scheme = "wss"
970 balancer := NewRandomBalancer([]*ProxyTarget{{URL: tgtURL}})
971
972 defaultTransport, ok := http.DefaultTransport.(*http.Transport)
973 if !ok {
974 t.Fatal("Default transport is not of type *http.Transport")
975 }
976 transport := defaultTransport.Clone()
977 transport.TLSClientConfig = &tls.Config{
978 InsecureSkipVerify: true,
979 }
980 e.Use(ProxyWithConfig(ProxyConfig{Balancer: balancer, Transport: transport}))
981 } else {
982 // proxy to non-TLS target
983 tgtURL, _ := url.Parse(srv.URL)
984 balancer := NewRandomBalancer([]*ProxyTarget{{URL: tgtURL}})
985 e.Use(ProxyWithConfig(ProxyConfig{Balancer: balancer}))
986 }
987
988 if serveTLS {
989 // serve proxy server with TLS
990 ts := httptest.NewTLSServer(e)
991 return ts
992 }
993 // serve proxy server without TLS
994 ts := httptest.NewServer(e)
995 return ts
996}
997
998// TestProxyWithConfigWebSocketNonTLS2NonTLS tests the proxy with non-TLS to non-TLS WebSocket connection.
999func TestProxyWithConfigWebSocketNonTLS2NonTLS(t *testing.T) {

Calls 4

NewRandomBalancerFunction · 0.85
ProxyWithConfigFunction · 0.85
CloneMethod · 0.45
UseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…