From 66e00b00cc4c5ccd67380a0f6927e8ecd1431886 Mon Sep 17 00:00:00 2001 From: Cristian Oliveira Date: Sat, 15 Jun 2024 21:09:17 +0200 Subject: [PATCH] feat: allow define services with ip (#166) * feat: allows declare service with IPs * bump version * remove debugs * fix tests --- .ergo | 1 + .version | 2 +- proxy/config.go | 4 ++++ proxy/config_test.go | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.ergo b/.ergo index 40ae183..67633be 100644 --- a/.ergo +++ b/.ergo @@ -9,3 +9,4 @@ two.domain http://localhost:8082 redislocal redis://localhost:6543 *.wildcard http://localhost:3030 withextraspace http://localhost:2222 +127.0.0.1:3034 mysitewithip diff --git a/.version b/.version index 5aff472..0eec13e 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -v0.4.1 +v0.4.2 diff --git a/proxy/config.go b/proxy/config.go index 589766d..1342fc6 100644 --- a/proxy/config.go +++ b/proxy/config.go @@ -228,6 +228,10 @@ func readServicesFromFile(filepath string) ([]Service, error) { name, urlWithPort = pair[0], pair[1] } + if !strings.Contains(urlWithPort, "://") { + urlWithPort = "http://" + urlWithPort + } + service, err := NewService(name, urlWithPort) if err != nil { return nil, fmt.Errorf("invalid service format `%v`. %v`", line, err) diff --git a/proxy/config_test.go b/proxy/config_test.go index 3a360a4..5e89592 100644 --- a/proxy/config_test.go +++ b/proxy/config_test.go @@ -39,7 +39,7 @@ func TestWhenHasErgoFile(t *testing.T) { }) t.Run("It loads the services redirections", func(t *testing.T) { - expected := 10 + expected := 11 service := len(config.Services) if expected != service {