Dot url parsing in resthelpers

29 views
Skip to first unread message

Ugo Bataillard

unread,
Mar 19, 2013, 9:20:32 PM3/19/13
to lif...@googlegroups.com
Dear community,

I have a problem with dot parsing in paths in RestHelpers.
I wanted to make an endpoint that looked like /api/user/<username> but my problem is that if there is a dot in the username the last part is lost.
Example 

serve("api/user/" prefix {
   
case Get(username :: Nil, _) =>{
    logger
.debug("Username = " + username)
 
}
}


If I try to reach it at ugo.m I will get Username = ugo

I saw this discussion https://groups.google.com/d/topic/liftweb/UwZQ8f2MmLE/discussion but what I would like to do is to disable explicitlyParsedSuffixes only for this request.

Is there any way to do that ?

Thank you in advance

Ugo

David Pollak

unread,
Mar 20, 2013, 1:42:38 PM3/20/13
to lif...@googlegroups.com
You could write your own extractor (see the code in RestHelper that implements Get.unapply) that treats the Req instance the way you want.
 

Thank you in advance

Ugo

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net

Ugo Bataillard

unread,
Mar 22, 2013, 3:28:32 AM3/22/13
to lif...@googlegroups.com
Thank you very much David.

I ended up with something like this

protected object GetWithSuffix {

   def unapply(r: Req): Option[(List[String], Req)] =

     if (r.get_?) Some(r.path.wholePath -> r) else None

}


But I still wonder if this couldn't be made a factory or something like LiftRules.defaultHeaders so we could have custom rules depending on the request.

Cheers,

Ugo

David Pollak

unread,
Mar 22, 2013, 9:02:32 AM3/22/13
to lif...@googlegroups.com
On Fri, Mar 22, 2013 at 12:28 AM, Ugo Bataillard <kns...@gmail.com> wrote:
Thank you very much David.

I ended up with something like this

protected object GetWithSuffix {

   def unapply(r: Req): Option[(List[String], Req)] =

     if (r.get_?) Some(r.path.wholePath -> r) else None

}


But I still wonder if this couldn't be made a factory or something like LiftRules.defaultHeaders so we could have custom rules depending on the request.

No.

First, the parsing of Req takes place way before its application to RestHelper.

Second, we've had many, many, many discussions of how to deal with suffixes and the system we have works for the vast majority of cases. In cases where it doesn't work, there's a very simple way to have the suffix appended like this one.
Reply all
Reply to author
Forward
0 new messages