Skip to content

Commit

Permalink
feat: allows declare service with IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed Jun 15, 2024
1 parent 942758b commit fc1d9fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ergo
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions proxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,21 @@ func readServicesFromFile(filepath string) ([]Service, error) {
}

urlPattern := regexp.MustCompile(`(\w+\:\/\/)?([^ ]+):(\d+)`)
fmt.Printf("@@@@@@@@ urlPattern %+v \n", urlPattern)

var name, urlWithPort string
first := urlPattern.MatchString(pair[0])
fmt.Printf("@@@@@@@@ first %+v \n", first)
if first {
name, urlWithPort = pair[1], pair[0]
} else {
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)
Expand Down

0 comments on commit fc1d9fa

Please sign in to comment.