0 notes &
Boolean matching in routes
Frankly, me and my fellow team members were sure that this stuff is useless. But latest comparison shows that we are actually loosing some points in this “find-the-difference-game”, so we finally decided to… emm… borrow the idea of arbitrary boolean matching into Circumflex. Here’s how it looks like:
get("/namecode/:name")
.and(param("name").startsWith("Ch")) = "You passed our namecode."
get("/namecode/:name") = "Never heard of '" + param("name") + "' before. Get lost!"
You can chain as many .and(...) as you want, using either regular matchers or boolean expressions. Each one will be evaluated only if all previous matches succeed. And moreover, each .and(...) section can reference match results from previous ones (our example shows how).
Cheers!