[Lift] Re: Rewrite to URL

2009-04-15 Thread marius d.

URL rewriting happens pretty early outside of rendering pipeline a S
is not yet available. Hence the exception being thrown and not caught.

Br's,
Marius

On Apr 15, 2:53 pm, wapgui  wrote:
> Hi,
>
> I want to rewrite to an URL. The request is 
> likehttp://localhost:8080/d/120a96bdbf7
> and 120a96bdbf7 is a database key for  
> http://localhost:8080/apps/save/newsreader1239792999415.wgt.
> So I added this to my Boot.scala
>
> LiftRules.rewrite.prepend {
>   case RewriteRequest(ParsePath("d" :: widget :: Nil, "", _,_), _, _)
> => {
>      val rUrl = SmUrl.getSmUrl(widget).roboSplit("/") //get URL from
> DB and split to List, this looks fine
>      RewriteResponse(rUrl)
>   }
>
> }
>
> In between I found out that RewriteResponse  is only working for Map
> entries. Now I used S.redirectTo instead of RewriteResponse and
> net.liftweb.http.ResponseShortcutException: Shortcut is thrown. Last
> try was to use LiftRules.DispatchPf like in us.esme.model.UrlStore but
> DispatchPf is not (longer?) a member of LiftRules.
> What else can I do?
>
> Cheers
> Torsten
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Rewrite to URL

2009-04-15 Thread wapgui

Thanks. If anybody needs it to:

LiftRules.dispatch.append {
  case r @ Req("d" :: widget :: Nil, _, GetRequest) => () =>
SmUrl.servUrl(widget, r)
}

and

def servUrl(url: String, r: Req): Box[LiftResponse] = {
  Full(RedirectResponse(SmUrl.getSmUrl(url)))
}


On Apr 15, 2:01 pm, Timothy Perrett  wrote:
> Take a look at:
>
> // Your boot.scala
> LiftRules.dispatch.append {
>   case Req(.)
>
> }
>
> Do a dispatch call and yeild a Box[RedirectResponse] (subtype of
> LiftResponse) and this will do what you need.
>
> Cheers, Tim
>
> On 15/04/2009 12:53, "wapgui"  wrote:
>
>
>
> > Hi,
>
> > I want to rewrite to an URL. The request is like
> >http://localhost:8080/d/120a96bdbf7
> > and 120a96bdbf7 is a database key for
> >http://localhost:8080/apps/save/newsreader1239792999415.wgt.
> > So I added this to my Boot.scala
>
> > LiftRules.rewrite.prepend {
> >   case RewriteRequest(ParsePath("d" :: widget :: Nil, "", _,_), _, _)
> > => {
> >      val rUrl = SmUrl.getSmUrl(widget).roboSplit("/") //get URL from
> > DB and split to List, this looks fine
> >      RewriteResponse(rUrl)
> >   }
> > }
>
> > In between I found out that RewriteResponse  is only working for Map
> > entries. Now I used S.redirectTo instead of RewriteResponse and
> > net.liftweb.http.ResponseShortcutException: Shortcut is thrown. Last
> > try was to use LiftRules.DispatchPf like in us.esme.model.UrlStore but
> > DispatchPf is not (longer?) a member of LiftRules.
> > What else can I do?
>
> > Cheers
> > Torsten

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Rewrite to URL

2009-04-15 Thread Timothy Perrett


Take a look at:

// Your boot.scala
LiftRules.dispatch.append {
  case Req(.)
}

Do a dispatch call and yeild a Box[RedirectResponse] (subtype of
LiftResponse) and this will do what you need.

Cheers, Tim


On 15/04/2009 12:53, "wapgui"  wrote:

> 
> Hi,
> 
> I want to rewrite to an URL. The request is like
> http://localhost:8080/d/120a96bdbf7
> and 120a96bdbf7 is a database key for
> http://localhost:8080/apps/save/newsreader1239792999415.wgt.
> So I added this to my Boot.scala
> 
> LiftRules.rewrite.prepend {
>   case RewriteRequest(ParsePath("d" :: widget :: Nil, "", _,_), _, _)
> => {
>  val rUrl = SmUrl.getSmUrl(widget).roboSplit("/") //get URL from
> DB and split to List, this looks fine
>  RewriteResponse(rUrl)
>   }
> }
> 
> In between I found out that RewriteResponse  is only working for Map
> entries. Now I used S.redirectTo instead of RewriteResponse and
> net.liftweb.http.ResponseShortcutException: Shortcut is thrown. Last
> try was to use LiftRules.DispatchPf like in us.esme.model.UrlStore but
> DispatchPf is not (longer?) a member of LiftRules.
> What else can I do?
> 
> Cheers
> Torsten
> 
> > 
> 



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---