Fairly new to Pharo/Seaside and it has been a long time since I used Smalltalk. I am trying to make a RESTful service and can not get it to work using the pragmas the way I think it should. Ie here is my list method within class TeamMembers which is a direct subclass of WARestfulHandler.
list
<get>
^ String streamContents: [ :stream |
self teamMembers do: [ :each |
stream nextPutAll: each ; crlf ] ]
After doing all the proper registration WAAdmin register: TeamMembers at: 'team-members' when I execute in the browser (http://localhost:8080/team-members) I received the message
/team-members not found
but if I execute (http://localhost:8080/team-members/list), it works as expected.
This seems to contradict the documentation in http://book.seaside.st/book/advanced/restful/getting-started/define-handler.
If I override the TeamMembers>>
createRoutes
| route |
route := WARoute get: '/listJson' selector: #listJson.
^OrderedCollection new
"GET"
add: route;
add: (WARoute get: #list);
yourself
Then I get the expected behaviour when I browse to (http://localhost:8080/team-members)
However, to get the Json output I still have to use (http://localhost:8080/team-members/listJson).
I have probably missed something pretty simple but any help is appreciated.
Using Pharo6.0-64.image with Seaside and this is how seaside was installed.
Metacello new
configuration:'Seaside3';
repository:
'http://www.smalltalkhub.com/mc/Seaside/MetacelloConfigurations/main';
version: #stable;
load.
Gofer new
squeaksource: 'Seaside30Addons';
package: 'Seaside-REST-Core';
package: 'Seaside-Pharo-REST-Core';
package: 'Seaside-Tests-REST-Core';
load.
Thanks
You need to add the <path: '/'>
pragma because you have more than one method with <get>
pragma and no arguments.