Open tailhook opened 7 years ago
So the idea is to create small DSL
Ouch, it looks creepy at the first sight...
So the idea is to create small DSL
Ouch, it looks creepy at the first sight...
So what are the alternatives? All ones mentioned in "motivation" section are clearly worse than this one. The nginx and caddy are basically example [2]. While linkerd has basically a mapping between a routing table and handler written as a weird DSL for rewrite rules (but note that linkerd has only proxying so it doesn't have our auth-rate-limit-error-page dilemma, and has access log only at granularity of protocol level as far as I can see).
Motivation
Currently, we have two tables matching urls
routing
andauthorization
, let's take an example [1]:The motivation was: if you need to specify authorization info in the handler, it's easy to omit it for child route and get a security issue. On the other hand, we can't introduce inheritance between handlers, like nginx does, because they are of very different types and we would need very complex rules of which settings are inherited between handlers when matching down the tree and which do not inherit.
In reality, we need more things that can be either inherited or not, and don't depend on a handler. Here is a list of all things we think could potentially have their own routing table:
Another point is: we need a compact and comprehensible routing table, i.e. the bad example [2]:
Few routes take a screenful of text, while in the real sites there are much more of them. Even if text editors can collapse mapping keys for you, they also hide important information.
Transposition isn't super-useful too, let's look at another bad example [3]:
While it's quite good for small table, but it scales too bad for multi-site installations.
Another alternative would be to introduce two-level table, here is another bad example [4]:
While at a glance this introduces short and comprehensible routing table, in which each site has their own settings, which also allows putting that section into another file, still it has shortcomings both ways:
/admin
section in the first example is actually another site (i.e. it has another handler, error pages, logs, access control and rate limits)Specification
So the idea is to create small DSL for making routing table compact:
DSL looks like:
@something
to the name of the handler uses the authorizersomething
for the route and all the enclosed routes->something
uses logger namedsomething
for the route and all enclosed routeserrors=something
as probably will be overridden more sparinglyNotes:
errors=
syntax is extensible toxx=yy
but we don't plan to add anything more here yet@something
umbrella, we think they are integrated quite closeUnsolved Problems
Sometimes unauthorized users should be presented different route than authorized. Currently we presume that it's application's problem, rather than the one of a frontend server.
/cc @popravich, @anti-social