Skip to content

Instantly share code, notes, and snippets.

@nickpelton
Created April 17, 2014 22:28
Show Gist options
  • Select an option

  • Save nickpelton/11015108 to your computer and use it in GitHub Desktop.

Select an option

Save nickpelton/11015108 to your computer and use it in GitHub Desktop.
PHP Quick Rest
<?php
$method = $_SERVER['REQUEST_METHOD'];
$request = explode("/", substr(@$_SERVER['PATH_INFO'], 1));
switch ($method) {
case 'PUT':
rest_put($request);
break;
case 'POST':
rest_post($request);
break;
case 'GET':
rest_get($request);
break;
case 'HEAD':
rest_head($request);
break;
case 'DELETE':
rest_delete($request);
break;
case 'OPTIONS':
rest_options($request);
break;
default:
rest_error($request);
break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment