-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Labels
featureNew feature or requestNew feature or request
Description
Let's suppose you have common handler for REST type API on some resource,
like /companies/.
So usual request pattern is :
- GET /companies(/?) - > get all companies
- GET /companies/:id -> get specific company
- PUT/POST/PATH/DELETE /companies/:id -> do something to specific company
Now all of the work can be done by the same handler , if it knows if :id is present.
I'm suggesting introduction of optional last param, e.g.
router.insert("/companies/:id?", whatever);
- accepts route /companies/
- accepts route /companies/some_id
router.insert("/companies/*catch_all?", whatever)
- same as above for route without param
- and general catchall behaviour is applied if param exists
Optional params should be supported only if they are in the route end ( which is obvious ) .
This would be easier than writing double insert in code that uses the library.
ibraheemdev
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request