TUN-2110: Implement custom deserialization logic for OriginConfig

This commit is contained in:
Chung-Ting Huang
2019-07-31 14:01:23 -05:00
parent 5feba7e3a9
commit bdd70e798a
52 changed files with 1874 additions and 4233 deletions

View File

@@ -86,7 +86,7 @@ func (s *StreamHandler) UpdateConfig(newConfig []*pogs.ReverseProxyConfig) (fail
s.tunnelHostnameMapper.DeleteAll()
for _, tunnelConfig := range newConfig {
tunnelHostname := tunnelConfig.TunnelHostname
originSerice, err := tunnelConfig.Origin.Service()
originSerice, err := tunnelConfig.OriginConfigUnmarshaler.OriginConfig.Service()
if err != nil {
s.logger.WithField("tunnelHostname", tunnelHostname).WithError(err).Error("Invalid origin service config")
failedConfigs = append(failedConfigs, &pogs.FailedConfig{

View File

@@ -49,8 +49,10 @@ func TestServeRequest(t *testing.T) {
reverseProxyConfigs := []*pogs.ReverseProxyConfig{
{
TunnelHostname: testTunnelHostname,
Origin: &pogs.HTTPOriginConfig{
URLString: httpServer.URL,
OriginConfigUnmarshaler: &pogs.OriginConfigUnmarshaler{
OriginConfig: &pogs.HTTPOriginConfig{
URLString: httpServer.URL,
},
},
},
}
@@ -97,8 +99,10 @@ func TestServeBadRequest(t *testing.T) {
reverseProxyConfigs := []*pogs.ReverseProxyConfig{
{
TunnelHostname: testTunnelHostname,
Origin: &pogs.HTTPOriginConfig{
URLString: "",
OriginConfigUnmarshaler: &pogs.OriginConfigUnmarshaler{
OriginConfig: &pogs.HTTPOriginConfig{
URLString: "",
},
},
},
}