Or you could use something like if you'r building REST API's:

LiftRules.dispatch.append {

   case Req("test" :: _, suffix, reqType) => // return a () =>
LiftResponse

}

or for non REST API you could use

LiftRules.statefulRewrite.append {

case RewriteRequest(ParsePath("test" :: _, _, _, _), reqType, request)
=> ...
}

Br's,
Marius

On Jan 10, 7:32 am, Brian Hsu <[email protected]> wrote:
> If I have a URL likehttp://localhost/Test/edit/{id} and I would like
> the {id} transform to a parameter instead of URL path part.
>
> The problem is that if I have a template named edit.html under webapp/
> Test, which is the template I use to edit an item.
>
> And I have a Menu instance like the following:
>
> <code>
> Menu (Loc("Test", List("Test") -> true, "Test"))
> </code>
>
> It would only match URL likehttp://localhost/Test/edit, not anything
> likehttp://localhost/Test/edit/1
>
> Is it best way to do it by create a menu with RewriteRequest? Because
> I found it a little boilerplate if I have lot URL pattern like this.
>
> <code>
> val menu = Menu(new Loc[Unit] {
>
>     override def name = "Test"
>     override def text = "Test"
>     override def link = (List ("Test"), true)
>     override def params = Nil
>     override def defaultValue = Full(())
>
>     def isTarget (path: ParsePath) = path match {
>         case ParsePath (List("Test", "edit", id), _, _, _) => true
>
>         case _ => false
>     }
>
>     override def rewrite = Full ( NamedPF("Test") {
>         case RewriteRequest (path, _, _) if isTarget(path) =>
>              RewriteResponse(List("Test", "edit"),
>                              Map("id" -> "1024")) -> ()
>
>     })})
>
> </code>
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to