@@ -94,19 +94,23 @@ public void activateBackend(String backendName)
9494 @ Override
9595 public ProxyBackendConfiguration addBackend (ProxyBackendConfiguration backend )
9696 {
97- dao .create (backend .getName (), backend .getRoutingGroup (), backend .getProxyTo (), backend .getExternalUrl (), backend .isActive ());
97+ String backendProxyTo = removeTrailingSlash (backend .getProxyTo ());
98+ String backendExternalUrl = removeTrailingSlash (backend .getExternalUrl ());
99+ dao .create (backend .getName (), backend .getRoutingGroup (), backendProxyTo , backendExternalUrl , backend .isActive ());
98100 return backend ;
99101 }
100102
101103 @ Override
102104 public ProxyBackendConfiguration updateBackend (ProxyBackendConfiguration backend )
103105 {
106+ String backendProxyTo = removeTrailingSlash (backend .getProxyTo ());
107+ String backendExternalUrl = removeTrailingSlash (backend .getExternalUrl ());
104108 GatewayBackend model = dao .findFirstByName (backend .getName ());
105109 if (model == null ) {
106- dao .create (backend .getName (), backend .getRoutingGroup (), backend . getProxyTo (), backend . getExternalUrl () , backend .isActive ());
110+ dao .create (backend .getName (), backend .getRoutingGroup (), backendProxyTo , backendExternalUrl , backend .isActive ());
107111 }
108112 else {
109- dao .update (backend .getName (), backend .getRoutingGroup (), backend . getProxyTo (), backend . getExternalUrl () , backend .isActive ());
113+ dao .update (backend .getName (), backend .getRoutingGroup (), backendProxyTo , backendExternalUrl , backend .isActive ());
110114 }
111115 return backend ;
112116 }
@@ -130,4 +134,9 @@ private static List<ProxyBackendConfiguration> upcast(List<GatewayBackend> gatew
130134 }
131135 return proxyBackendConfigurations ;
132136 }
137+
138+ public static String removeTrailingSlash (String url )
139+ {
140+ return url .replaceAll ("/$" , "" );
141+ }
133142}
0 commit comments