-
Notifications
You must be signed in to change notification settings - Fork 3
Resource
dscape edited this page Mar 4, 2011
·
2 revisions
Some resource only expose a single item, e.g. your about page. While you might want to be able to perform CRUD actions on a about page there is only one about page so using resources
(plural) would be useless.
When you create a resource
in rewrite
you expose these actions:
Verb | Path | Action | Notes | Default Mapping |
---|---|---|---|---|
GET | /about | get | Display about section | /resource/about.xqy&action=get |
PUT | /about | put | Creates or updates the about section | /resource/about.xqy&action=put |
DELETE | /about | delete | Deletes the about section | /resource/about.xqy&action=delete |
POST | /about | post | No special meaning | /resource/about.xqy&action=post |
GET | /about/edit | edit | Return a form to create/edit the about section | /resource/about.xqy&action=edit |
The following example illustrates a resource:
Request : GET /about
routes.xml : <routes>
<resource name="about"/>
</routes>
Dispatches to : /resource/about.xqy?action=get
As with get
, put
, etc, you can also create a dynamic resource by prefixing the name with :
. Here's an example of using this to create a database:
Request : PUT /documents
routes.xml : <routes>
<resource name=":database"/>
</routes>
Dispatches to : /resource/database.xqy?action=put&database=Documents
For more information refer to the Dynamic Paths section of the wiki.
Request : PUT /car/ignition
routes.xml : <routes>
<resources name="car">
<member action="ignition" for="PUT,DELETE"/>
</resources>
</routes>
Dispatches to : /resource/users.xqy?action=ignition