[Seaside] Seaside-Rest question [WAS] Re: How can I make this kind of redirect in Seaside?

Esteban A. Maringolo emaringolo at gmail.com
Wed Jul 19 12:43:47 UTC 2017


2017-07-18 19:57 GMT-03:00 Mariano Martinez Peck <marianopeck at gmail.com>:

> BTW... how can I allow something like this:
>
> <path: '/companyreport/{ticker}/{reportName}'>
>
> I then somehow I would like to parse the URL inside the method so that I
> answer the correct response based on the URL ...


You should have a method like:

getTicker: ticker report: reportName
  <get>
  <path: '/companyreport/{ticker}/{reportName}'>

There you'll have the ticker and reportName placeHolders mapped to the
argument variable names. It is, the arguments of the method will hold
whatever you put in those placeholders.

But keep in mind this will only match a URI as a whole, if for some
reason you add query parameters to the request, like
'/companyreport/AAPL/dailyChange?format=csv', you'll need another
method, with another name and path pragma.

That's why I implemented the "variableQuery" pragma [1], so you can
have a fixed URI but variable queries mapped to a single smalltalk
method. But it was removed [2] because there was a proper way [3] of
implementing it I ignored/didn't understand at that time.

This part of the framework is powerful, but certainly lacking
examples, and without the behavior of [1] or [3] is too rigid for a
flexible API.

I could explain how it works, and use it as I do, but I can't tell I
completely understand it as probably its creator does.

Regards,

Esteban A. Maringolo

[1] http://forum.world.st/New-Seaside-REST-Core-extension-td4872995.html
[2] http://forum.world.st/REST-quot-variable-queries-quot-td4941376.html#a4941377
[3] http://lists.squeakfoundation.org/pipermail/seaside/2014-December/031314.html


More information about the seaside mailing list