-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Router/Resource interaction #6
Comments
"/\d+/posts/" might be a bad example here. Is there a way to provide extra data down into a route? Or maybe we need a way to have routes redirect within the router. Basically, should it be "/\d+/posts/" or should the user module depend on the blog_posts_resource, which uses the posts uri, and has a "///" route. |
maybe this isn't best. Look into building a way to generate child resources? or mixed resources. |
Added research tag. This should be decided on after some common use cases have been developed (a more advanced example resource, and some sub_example resources) |
This uses the technique of stripping out the resource uri on each request. Maybe the right technique is a combination. eg. example depends on user and blog_post /user/5/posts The last one seems like the best technique, but I'm not sure how intuitive that would end up. This all seems way too complicated. For the moment maybe we keep this uri stripping thing in as a test, and just assume people use one level of hierarchy. it will be more like the traditional controller scheme that people are used to. |
Currently, the example uses an empty uri, and then the first level sub routes have /user/, /posts/ etc. This is useful for routing from within a resource. |
When a resource performs a route, it should strip the resources uri from the route and pass it to the router.
This should also happen when chaining through into child routes.
eg.
var zaft_resource = { uri : '/' , dependencies : ['user']};
var user_resource = { uri : 'user/' };
zaft_resource.route('/user/123');
//pull off the forward slash for the zaft_resource, so we are routing based on user/123
//check all children for a match
// if found
// pass into appropriate resource (in this case it's the user resource because 'user/123' is prefixed by the user_resources uri of 'user/'
// Go back to top, which will pull off 'user/', so we are simply routing based on the uri of '123'. This will not find any resources, so it goes to the routes and locates the route for /\d+/
// if not found, check all routes for a match
We might want this to be configurable, because it's a slightly odd logic flow.
The intent is to widen the use of common modules, by abstracting away the full uri.
Having a user module with the following routes would enable it to be used on a wider range of sites
/// : post = add, delete = remove
/\d+/ : get = read, put = update
/\d+/posts/ : get = read all posts, post = assign a post to a user
And then users can just change the uri config, and enable it across all sorts of sites.
The text was updated successfully, but these errors were encountered: