[Seaside] REST client?
Sven Van Caekenberghe
sven at beta9.be
Wed Nov 16 18:24:19 UTC 2011
On 16 Nov 2011, at 18:32, Lukas Renggli wrote:
> Zinc, and it is included with Pharo.
>
> http://homepage.mac.com/svc/Zinc-HTTP-Components/getting-started.html
Indeed, the new ZnClient can do transparent encoding/decoding using the #contentReader: and #contentWriter: options, like this:
ZnClient new
systemPolicy;
url: 'http://easy.t3-platform.net/rest/geo-ip';
queryAt: 'address' put: '81.83.7.35';
accept: ZnMimeType applicationJson;
contentReader: [ :entity | | parserClass |
parserClass := Smalltalk at: #JSJsonParser ifAbsent: [ ^ self ].
parserClass parse: entity contents ];
ifFail: [ ^ self error: 'Oops' ];
get.
If you set a #contentWriter: to convert Smalltalk to your representation, you can provide put/post data using #contents: with Smalltalk objects as arguments. The same can be done for XML, or any other (custom) encoding.
Sven
More information about the seaside
mailing list