Problem mapping a request for a REST Api

7 views
Skip to first unread message

andythedestroyer

unread,
Oct 29, 2009, 5:27:10 PM10/29/09
to Lift
Hello,

I am creating a rest api for an app and am having trouble extracting a
var from the matched request.

Object MyApi extends XMLHelperApi {
def dispatch : LiftRules.DispatchPF = {
case Req(List("api","package", packageName), _, GetRequest)
=>
() => myMethodThatDoesSomething(packageName)
}
}

The packageName variable is in the form similar but not exactly like
java package names ( my.company.package:key=value )

so the rest url would be

http://domain.com/api/package/my.company.package%3Akey%3Dvalue

This should work and the package var in my case expression should be
"my.company.package:key=value" but it is just "my".

I have gone through "The Definitive Guide to Lift" and the group
postings but have had no luck so far. I know this should be easy and I
am just missing something.

Thanks
Andy

Naftoli Gugenheim

unread,
Oct 29, 2009, 5:32:02 PM10/29/09
to lif...@googlegroups.com
List("api", "package", packageName : _* )

-------------------------------------

David Pollak

unread,
Oct 29, 2009, 6:12:11 PM10/29/09
to lif...@googlegroups.com
When Lift parses a path, the last element of the path is split at the first '.'.  This allows you to match of "foo" :: "bar", "jpg" vs. "foo" :: "bar", "png"

However, this is biting you right now... and  I've got a solution.

Please open a ticket at http://github.com/dpp/liftweb/issues and I'll get it fixed.
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

andythedestroyer

unread,
Oct 29, 2009, 6:39:53 PM10/29/09
to Lift
Thanks for the response but that doesn't work. I get the following
error.

[WARNING] API.scala:51: error: ')' expected but identifier found.
[WARNING] case Req(List("api" , "package" , packageName : _*), "",
GetRequest) =>

-Andy

On Oct 29, 2:32 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> List("api", "package", packageName : _* )
>
> -------------------------------------
>

andythedestroyer

unread,
Oct 29, 2009, 6:41:32 PM10/29/09
to Lift
Thanks for the response. The ticket number is 144 and here is the link
http://github.com/dpp/liftweb/issues/#issue/144

-Andy

On Oct 29, 3:12 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> When Lift parses a path, the last element of the path is split at the first
> '.'.  This allows you to match of "foo" :: "bar", "jpg" vs. "foo" :: "bar",
> "png"
>
> However, this is biting you right now... and  I've got a solution.
>
> Please open a ticket athttp://github.com/dpp/liftweb/issuesand I'll get it
> fixed.
>
> On Thu, Oct 29, 2009 at 2:27 PM, andythedestroyer <
>
>
>
>
>
> andythedestro...@gmail.com> wrote:
>
> > Hello,
>
> > I am creating a rest api for an app and am having trouble extracting a
> > var from the matched request.
>
> > Object MyApi extends XMLHelperApi {
> >     def dispatch : LiftRules.DispatchPF = {
> >           case Req(List("api","package", packageName), _, GetRequest)
> > =>
> >                 () => myMethodThatDoesSomething(packageName)
> >     }
> > }
>
> > The packageName variable is in the form similar but not exactly like
> > java package names ( my.company.package:key=value )
>
> > so the rest url would be
>
> >http://domain.com/api/package/my.company.package%3Akey%3Dvalue
>
> > This should work and the package var in my case expression should be
> > "my.company.package:key=value" but it is just "my".
>
> > I have gone through "The Definitive Guide to Lift" and the group
> > postings but have had no luck so far. I know this should be easy and I
> > am just missing something.
>
> > Thanks
> > Andy
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890

David Pollak

unread,
Oct 29, 2009, 7:23:11 PM10/29/09
to lif...@googlegroups.com
On Thu, Oct 29, 2009 at 3:41 PM, andythedestroyer <andythed...@gmail.com> wrote:

Thanks for the response. The ticket number is 144 and here is the link
http://github.com/dpp/liftweb/issues/#issue/144


I've got a fix that I'm testing.  I hope to get it into the code before the code slush today.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

andythedestroyer

unread,
Oct 29, 2009, 7:54:43 PM10/29/09
to Lift
You rule!

On Oct 29, 4:23 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Thu, Oct 29, 2009 at 3:41 PM, andythedestroyer <
>
> andythedestro...@gmail.com> wrote:
>
> > Thanks for the response. The ticket number is 144 and here is the link
> >http://github.com/dpp/liftweb/issues/#issue/144
>
> I've got a fix that I'm testing.  I hope to get it into the code before the
> code slush today.
>
>
>
>
>
> > -Andy
>
> > On Oct 29, 3:12 pm, David Pollak <feeder.of.the.be...@gmail.com>
> > wrote:
> > > When Lift parses a path, the last element of the path is split at the
> > first
> > > '.'.  This allows you to match of "foo" :: "bar", "jpg" vs. "foo" ::
> > "bar",
> > > "png"
>
> > > However, this is biting you right now... and  I've got a solution.
>
> > > Please open a ticket athttp://github.com/dpp/liftweb/issuesandI'll get

David Pollak

unread,
Oct 29, 2009, 7:57:51 PM10/29/09
to lif...@googlegroups.com
http://reviewboard.liftweb.net/r/77/
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

Naftoli Gugenheim

unread,
Oct 30, 2009, 12:17:41 AM10/30/09
to lif...@googlegroups.com
Sorry--it was a bad guess. I should have written "try" etc...

-------------------------------------
andythedestroyer<andythed...@gmail.com> wrote:


Thanks for the response but that doesn't work. I get the following
error.

[WARNING] API.scala:51: error: ')' expected but identifier found.
[WARNING] case Req(List("api" , "package" , packageName : _*), "",
GetRequest) =>

-Andy

On Oct 29, 2:32 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> List("api", "package", packageName : _* )
>
> -------------------------------------
>

andythedestroyer

unread,
Oct 30, 2009, 7:28:02 PM10/30/09
to Lift
No problem. I sincerely appreciate all suggestions.

It looks like dpp is already working on a fix for this. I came up with
the really ugly ( but temporary solution until the fix in commited )
of appending meaningless info to the url.
so
http://domain.com/api/package/my.company.package%3Akey%3Dvalue

becomes

http://domain.com/api/package/my.company.package%3Akey%3Dvalue/foobar

and it works.

Thanks again,
A

On Oct 29, 9:17 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> Sorry--it was a bad guess. I should have written "try" etc...
>
> -------------------------------------
>
Reply all
Reply to author
Forward
0 new messages