glaforge/gaelyk — Issue #107: RoutesFilter - Ability to define or modify variables in validate method
Author: codeconsole
Created: 2012-01-26 06:06:26+00:00
State: open

For example, if you wanted to redirect all appspot requests to an owned domain:

all "@path", validate: {
var mydomain = "www.twitter.com"
request.requestURL.toString().matches("http://[\\w\\-]+\\.appspot\\.com.*")
}, redirect: "https://@mydomain@path"

Obviously the setting of the var would be more dynamic in real life. For example, I have a filter that sets my dynamic properties in the request scope. So I could say:

var mydomain = request.mydomain