I wanna create 2 separate handlers for 2 routes below, first will do collections' actions, second - document related things. Two regex are needed for that.
That pattern
^\/api\/([\w]+)\/([\w]+)(\/([a-f0-9]{24}))?\/?\??.*$
covers all two cases
1)
/api/appslug/collectionname
/api/appslug/collectionname/
/api/appslug/collectionname?key=val
/api/appslug/collectionname/?key=val
/api/appslug/collectionname?key=val&hello=there
/api/appslug/collectionname/?key=val&hello=there
2)
/api/appslug/collectionname/5919a81f318139c5157636f9
/api/appslug/collectionname/5919a81f318139c5157636f9/
/api/appslug/collectionname/5919a81f318139c5157636f9?key=val
/api/appslug/collectionname/5919a81f318139c5157636f9/?key=val
/api/appslug/collectionname/5919a81f318139c5157636f9?key=val&hello=there
/api/appslug/collectionname/5919a81f318139c5157636f9/?key=val&hello=there
How to create separate pattern for routes containing mongo id ?
Thanks!