There were some people asking about Zinc-REST. I took some time to improve the 
package (by moving some private code into it) and documented it by adding a 
couple of examples and unit tests.

Load the group 'REST' using the latest ConfigurationOfZincHTTPComponents 
(NeoJSON will be loaded as a dependency).

There are two examples:

(1)

ZnExampleSumRestCall handles REST requests for /sum

For a GET request, it accepts numbers as path elements or as a query parameter.

        GET /sum/1/2/3
        GET /sum?numbers=1,2,3
        
For a POST requests, it accepts a text/plain entity containing numbers.

        POST /sum '1,2,3'
        
(2) 

ZnExampleStorageRestServerDelegate offers a REST interface on /storage/objects 
with CRUD operations on JSON maps.

GET /storage/objects

        list all stored maps as a list of object-uris
        
GET /storage/objects?key1=value1&key2=value2

        as above with conjunctive condition specified 
        
POST /storage/objects <MAP>
        
        store a new map, returns the created object-uri

GET /storage/object/<id>

        return the map stored under id
        
DELETE /storage/object/<id>

        delete the map stored under id
        
PUT /storage/object/<id> <MAP>

        overwrite the map stored under id with MAP


Both examples are tested by matching unit tests.

There is no further independent textual documentation, you'll need to know what 
REST style interfaces are and know about Zinc HTTP Components.

Compared to Seaside-REST this solution is simpler (no Seaside dependency), a 
bit less declarative (no pragmas), closer to the mechanics of HTTP, not linked 
to automagic conversions (Magritte). But this is code that I use in production.


Sven

--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill


Reply via email to