TUN-2111: Implement custom serialization logic for FallibleConfig and OriginConfig

This commit is contained in:
Chung-Ting Huang
2019-08-05 10:14:58 -05:00
parent 993a9bc4b9
commit fd4ab314dc
6 changed files with 289 additions and 100 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.OriginConfigUnmarshaler.OriginConfig.Service()
originSerice, err := tunnelConfig.OriginConfigJSONHandler.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,7 +49,7 @@ func TestServeRequest(t *testing.T) {
reverseProxyConfigs := []*pogs.ReverseProxyConfig{
{
TunnelHostname: testTunnelHostname,
OriginConfigUnmarshaler: &pogs.OriginConfigUnmarshaler{
OriginConfigJSONHandler: &pogs.OriginConfigJSONHandler{
OriginConfig: &pogs.HTTPOriginConfig{
URLString: httpServer.URL,
},
@@ -99,7 +99,7 @@ func TestServeBadRequest(t *testing.T) {
reverseProxyConfigs := []*pogs.ReverseProxyConfig{
{
TunnelHostname: testTunnelHostname,
OriginConfigUnmarshaler: &pogs.OriginConfigUnmarshaler{
OriginConfigJSONHandler: &pogs.OriginConfigJSONHandler{
OriginConfig: &pogs.HTTPOriginConfig{
URLString: "",
},