Closed acobster closed 5 years ago
Example use case:
class MyController extends WP_REST_Controller { public function say_hi(WP_Rest_Request $request) { return sprintf("Hi, %s!", $request->get_param('name')); } } $controller = new MyController(); $router = new Conifer\Rest\Router; $router->set_namespace('/my-project-namespace/v1') // GET /hi/coby -> "Hi, coby!" ->add_get('/hi/:name', [$controller, 'say_hi']);
See Adding Custom Endpoints. The calls to set_namespace and add_get would be the equivalent of:
set_namespace
add_get
register_rest_route('/my-project-namespace/v1', '/hi/(?P<name>\[a-z]+)', [ 'methods' => 'GET', 'callback' => [$controller, 'say_hi'], ]);
Example use case:
See Adding Custom Endpoints. The calls to
set_namespace
andadd_get
would be the equivalent of: