Spent the last hour trying to figure out why my @after annotations weren't working. I don't think it's necessarily a bug but it's something to watch out for and I thought posting here would help future Internet searchers.
Adapting the example REST code, this doesn't work:
interface Example5API
{
@before!authenticate("user") @after!addBrackets
string getSecret(int num, User user);
}
while this code does work:
interface Example5API
{
@before!authenticate("user") @after!addBrackets()
string getSecret(int num, User user);
}
The difference is the subtle omission of parentheses on the @after
annotation. I am accustomed to omitting these with D's lenient property syntax and got bit by it here. Unfortunately both versions compile and run, but in the paran-less version, the addBrackets
handler is silently never called.