endpoint-factories

Take a WP route string (with PCRE named capture groups), such as /author/(?P<id>\d+), and generate request handler factory methods for each represented endpoint.

Methods

(inner) generate(namespace, routesByNamespace) → {object}

Given an array of route definitions and a specific namespace for those routes, recurse through the node tree representing all possible routes within the provided namespace to define path value setters (and corresponding property validators) for all possible variants of each resource's API endpoints.

Source:
Parameters:
Name Type Description
namespace string

The namespace string for these routes

routesByNamespace object

A dictionary of namespace - route definition object pairs as generated from buildRouteTree, where each route definition object is a dictionary keyed by route definition strings

Returns:
Type:
object

A dictionary of endpoint request handler factories