CodeIgniter Forums
Difference between Add and Get in route - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Difference between Add and Get in route (/showthread.php?tid=75668)



Difference between Add and Get in route - seunex - 03-03-2020

What is the difference between $Routes->get and $Routes->add


RE: Difference between Add and Get in route - Hielemedia - 03-03-2020

(03-03-2020, 02:26 AM)seunex Wrote: What is the difference between $Routes->get and $Routes->add
From what i understand add() just adds a 'universal' route (for get, post etc calls) and get() ads a route for $_GET requests (used with RESTFULL  API for example)


RE: Difference between Add and Get in route - kilishan - 03-03-2020

add makes it available across all HTTP verbs, while get will only respond to GET requests. You'll have better security to limit each route only to the HTTP verb that it needs, so I would recommend NOT using add() personally.