views:

156

answers:

1
+4  A: 

Any lowercased variable in a case statement will create a new variable with that name, therefore requestList is going to be shadowed. Try this:

val requestList = "abc" :: Nil

LiftRules.statelessRewrite.append {
  case RewriteRequest(ParsePath(list, _ , _ , _ ), _ , _ ) if list == requestList =>
    RewriteResponse("index" :: Nil)
}

Another approach would be to use backticks (Scala ref: ‘stable identifier patterns’):

LiftRules.statelessRewrite.append {
  case RewriteRequest(ParsePath(`requestList`, _ , _ , _ ), _ , _ ) =>
    RewriteResponse("index" :: Nil)
}    

In your case, the second form would be the canonical one to choose, but in general the first form will be more powerful.

As a third alternative, you could also define val RequestList = requestList and match against the uppercased version, though I would advise against this unless you have a good reason for creating a capitalised RequestList.

Debilski