Skip to content

Commit

Permalink
Add support for raw tags
Browse files Browse the repository at this point in the history
Raw tags add arbitrary route commands to the routing
table. The current approach needs review but works.

By prefixing a tag with 'fabio ' the following text
will be added to the routing table.

See #87
  • Loading branch information
magiconair committed Feb 27, 2018
1 parent 16805a9 commit 964a9e7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions registry/consul/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,24 @@ func serviceConfig(client *api.Client, name string, passing map[string]bool, tag
continue
}

// get all tags which do not have the tag prefix
// get all tags which do not have the tag prefix or the raw tag prefix
const rawPrefix = "fabio "
var svctags []string
for _, tag := range svc.ServiceTags {
if !strings.HasPrefix(tag, tagPrefix) {
if !strings.HasPrefix(tag, tagPrefix) && !strings.HasPrefix(tag, rawPrefix) {
svctags = append(svctags, tag)
}
}

// generate route commands
for _, tag := range svc.ServiceTags {
// add raw tags as is
if strings.HasPrefix(tag, rawPrefix) {
tag = strings.TrimSpace(tag[len(rawPrefix):])
config = append(config, tag)
continue
}

if route, opts, ok := parseURLPrefixTag(tag, tagPrefix, env); ok {
name, addr, port := svc.ServiceName, svc.ServiceAddress, svc.ServicePort

Expand Down

0 comments on commit 964a9e7

Please sign in to comment.