Next: Starting the API, Previous: API definition, Up: Top [Contents][Index]
APIs need to implement its resources operations. This is done via the implement-resource-operation macro.
Define an resource operation implementation
The required arguments of the resource operation appear as normal arguments in the function, in the order in which they were declared. The optional arguments of a resource operation appear as &key arguments of the function. In case the resource operation request method is either `PUT' or `POST', then a >>‘‘<<posted-content‘ argument should be added to the implementation function as the first argument.
Some examples:
For this operation:
(get-user (:request-method :get :produces (:json) :path "/users/{id}" :documentation "Retrive an user") ((id :integer "The user id") &optional (expand :list nil "Attributes to expand")))
The following resource implementation should be defined:
(implement-resource-operation get-user (id &key expand) (serialize (find-user id) :expand expand))
And for this POST operation:
(create-user (:request-method :post :consumes (:json) :path "/users" :documentation "Create a user" :body-type user) ())
The posted-content
argument should be included:
(implement-resource-operation create-user (posted-content) (with-posted-content (name age) posted-content (serialize (model:create-user :name name :age age))))
Next: Starting the API, Previous: API definition, Up: Top [Contents][Index]