Skip to content

Add raw tags #455

@magiconair

Description

@magiconair

Fabio currently uses specially crafted Consul tags (urlprefix-host/path opt opt ...) to generate route commands which build the fabio routing table. There is a certain impedance mismatch between the syntax of the urlprefix- tags and the route add commands they generate, e.g.

urlprefix-/
route add <svcname> / http://<svcaddr>/

urlprefix-/ strip=/foo
route add <svcname> / http://<svcaddr>/ opts "strip=/foo"

urlprefix-:1234 proto=tcp
route add <svcname> :1234 tcp://<svcaddr>/

urlprefix-/ proto=https
route add <svcname> / https://<svcaddr>/

It would be useful if the urlprefix- tags are just a convenient shorthand notation for common more complex route commands but users could choose to express the same thing as a route command as well. This would limit the syntax of the urlprefix- commands to what is necessary for the most common uses cases.

For this to work, the code would need to distinguish between two types of tags: short and raw

raw tags are added verbatim (without the tag prefix) to the routing table whereas the short tags provide a special shorthand notation syntax which needs to be parsed and transformed.

Additionally, the raw tags need pseudo-variables to inject the service name and service address which are currently generated from the urlprefix- tags to be fully equivalent.

urlprefix-/ could then also be written as fabio route add $service / http://$addr/ assuming that fabio is the raw prefix tag.

The open questions are whether there should be a different prefix for the raw tags or whether this should be rolled into the urlprefix- syntax. Since the urlprefix- syntax is already used for defining TCP services I think we shouldn't overload it even further.

I'd like to gather some ideas on the syntax of a fabio tag for defining routes and allowing raw route commands and then we start with the route commands.

Note

There is an open issue/pr somewhere which has these ideas but I can't find it right now. Will update when I do.

Note2

Part of the discussion is in #87 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions