-
Notifications
You must be signed in to change notification settings - Fork 1
Static Routes
chernser edited this page Sep 22, 2012
·
2 revisions
Static routes were done to support context bound URI's, like '/session' which content depends on some conditions, current user, for example.
Difference between common resource, accessed by ID, and static route is actually missing ID. Because of this static routes are implemented as list of static prefix, bound resource name and id function.
Id Function - is called to determinate ID of bound resource while processing POST, GET, PUT and DELETE. It should return query object, like {id: 123, id_field: "user_id"}
. Request is passed to this function as first parameter
NOTE: Id functions MUST have name 'id_fun'
Example:
function id_fun(req) {
var user_id = req.query.user_id;
return {id: user_id, id_field: "user_id"};
}
If resource is not found by provided identification info, 404 is returned.