I'm writing a config file for grails app where I want to define redirect patterns.
I've written a config script RedirectMappingsConfig.groovy:
import java.util.regex.Pattern
def c = {pattern, goto, path ->
if (pattern instanceof Pattern && pattern.matcher(path).matches()) {
return goto
}
return false
}
def redirectFromTo = [
c.curry(Pattern.compile('/si/reference.*'), '/enterprise-solutions/references-and-partners#references'),
c.curry(Pattern.compile('/si/kontakt.*'), '/contact-us'),
c.curry(Pattern.compile('/si/zaposlitve.*'), '/careers'),
c.curry(Pattern.compile('/aa'), '/')
]
This list will be read in a filter which will perform redirect if some pattern matches request uri.
Problem: application does not compile, the error is:
Compilation error: startup failed:
RedirectMappingsConfig.groovy: 3: unexpected token: pattern @ line 3, column 10.
def c = {pattern, goto, path ->
^
Any idea what is wrong with the syntax?
I'm using grails 2.1.1.