Advertisement
azurenote

REST METHOD switch

May 27th, 2015
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.25 KB | None | 0 0
  1. function fork_http_method(array $methods)
  2. {
  3.     return function() use ($methods)
  4.     {
  5.         $what = $_SERVER['REQUEST_METHOD'];
  6.  
  7.         if (!array_key_exists($what, $methods))
  8.             api_error('This method is not implemented.', 501);
  9.        
  10.         $methods[$what]();
  11.     };
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement