WP Manifestindependent plugin directory
manifest / integrations / hc-rest-routes

H+C Rest Routes

Rest Routes API wordpress plugin

by Howatson + Co · github.com/howatsonco/hc-rest-routes · website

0stars
1.5kcomposer installs
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/howatsonco/hc-rest-routes/archive/refs/heads/prod.zip

Also on Packagist as hc/rest-routes:

composer require hc/rest-routes

From the readme

Introduction A plugin for custom API routing. Made with love by Howatson+Co. Usage There are two parts to using this plugin: 1. Defining API routes 2. Defining custom controllers for handling response logic To do either of these, you will need to first access the Rest API Server class instance. This can be achieved either by calling the global scope function HCRR like this: Or, by accessing the global scope variable assigned: Defining Routes You can define a route through the registerRoute method attached to the Router class, like so: The registerRoute method takes three arguments: - API URI pattern to be matched for this route to be executed. This can be a regex string. - Name of Controller to instantiate. - Name of method attached to Controller to execute. Defining Controllers When defining Controllers, adhere to the following rules: - The controller must extend \HC\RestRoutes\Abstracts\ControllerAbstract - Controller methods should be named ${name}${httpVerb}, where: - name is the name you pass to the route, and - httpVerb is the HTTP verb of the request (e.g GET, POST, PUT, etc) - Return the data you want to respond with. - Throw a RestfulException provided by the

Read the full README on GitHub →