-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper expression language (EL) for conditions #102
Comments
Authorino's Authorino's selectors are JSON paths that not only represent a value (fetched from the Authorization JSON) but also accept functions (“string modifiers”). |
Looking at where this comes from today, and if we wanted to move away from the conditions requiring an evaluation, the "natural" way of expressing would be like: {
key: "req.method",
exact_match: "GET"
} |
Not quite sure what people's preference is here, but I'll come with mine…
There are a few reason for this, but mostly this is the most straight forward change, but mostly addresses the type system clearly… unlike splitting the condition in 3 distinct parts… how is the type of the value expressed? And I know there is only Trying to answer this, as this impacts how we make progress on wrapping up |
Currently
conditions
for alimit
have the current format:Where left-hand side (lhs) has to be the
variable
to look up and the right-hand side (rhs) the value it'll be tested against. Currently we only support the equality operator (==
) and further more, only the format where it has a white space before and after the operator is actually supported (where more spaces will probably not have the result one would expect).I started some work on parsing these condition using a proper scanner which turns the input
&str
(each condition) into tokens (identifier, operator & ... aString
literal). But right now it still has to fallback to position to know which is the identifier (lhs) and which is the value (rhs). I think that's less optimal and possibly creates really surprising things to read, as e.g.get == GET
would be a valid condition.I'm proposing to have
String
literals just be… string literals as one would know them from different programing languages or... yaml for this matter (i.e. surrounded by quotation ("
or'
) marks). That would achieve a few things:method == "GET"
and"GET" == method
are equivalent, as one would expect as==
is commutative.What would that EL look like tho?
"
) or/and single ('
) quotes?String
value in there, so we don't need to supportNumber
literals, right?\
) for escaping? Using both single & double quotes?The downside is that would be a breaking change. Existing
limits.yaml
file would be "wrong". I already wanted to eagerly parse the conditions when parsing thelimits.yaml
file (unlike the lazy way of today). So we could give a good error message to users when the scanner would have a[TokenType::Identifier, TokenType::Operator, TokenType::Identifier]
when it'd expect one (and probably the last one) to be aTokenType::Literal
instead.tl;dr
Have condition be in the format of:
todo
TryFrom<&str> for Condition
by a properScanner
impl.The text was updated successfully, but these errors were encountered: