How to block execution of controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to block execution of controller (/showthread.php?tid=68204) |
How to block execution of controller - NickOver - 06-08-2017 Hi! I wanna make a rest api using codeigniter. So i create new core element MY_Controller which extend CI_Controller. I make simple annotation parser but now i have a problem. How i can block execution if http method from annotation doesnt match request http method? I don't wanna use die(), im not a animal Below an example: GET user/add Method in controller/User.php: PHP Code: /** In that case i don't have method for GET request so i must block that (return error), but how i can do it? Best regards NickOver RE: How to block execution of controller - skunkbad - 06-08-2017 Check against $_SERVER['REQUEST_METHOD']. PHP Code: if( strtolower( $_SERVER['REQUEST_METHOD'] ) != 'get' ) RE: How to block execution of controller - NickOver - 06-09-2017 My problem isn't get request method or show something to user. I must, in layer between CI_Controller and controller, stop execution controller code. Something like die() but with execution hooks. RE: How to block execution of controller - Narf - 06-09-2017 I'll just leave this here: https://codeigniter.com/userguide3/general/routing.html#using-http-verbs-in-routes RE: How to block execution of controller - Paradinight - 06-09-2017 (06-09-2017, 02:43 AM)NickOver Wrote: My problem isn't get request method or show something to user. I must, in layer between CI_Controller and controller, stop execution controller code. Something like die() but with execution hooks. PHP Code: $route['products']['get'] = 'product/list_all'; or https://www.codeigniter.com/user_guide/general/controllers.html#remapping-method-calls |