How to block execution of controller |
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
Check against $_SERVER['REQUEST_METHOD'].
PHP Code: if( strtolower( $_SERVER['REQUEST_METHOD'] ) != 'get' )
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.
I'll just leave this here: https://codeigniter.com/userguide3/gener...-in-routes
(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/g...thod-calls |
Welcome Guest, Not a member yet? Register Sign In |