Conversation
Registers GET /waygate/v1/patterns (requires edit_posts) and POST /waygate/v1/pages (requires publish_pages) under the waygate/v1 namespace. Both endpoints delegate to existing Pattern_Lab methods; failed page creation returns a 422 WP_Error.
Adds RestApiTest (14 tests) covering route registration, get_patterns filtering, and create_page success/error paths. Extends bootstrap.php with WP_REST_Request/Response/Server stubs and REST helper function stubs.
POST /waygate/v1/pages now always creates drafts; the status parameter has been removed to prevent accidental publishing via the API. Adds a per-user transient-based rate limiter (10 req/60 s) in the permission callback, returning 429 when exceeded. The limit is filterable via waygate_rate_limit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This release introduces a REST API layer for Waygate v0.7.0, exposing two authenticated endpoints for pattern listing and page creation directly over HTTP. The new
REST_APIclass registers routes under thewaygate/v1namespace, enabling programmatic access to pattern data and AI-driven page generation without requiring the WordPress admin UI. Page creation via the REST API is restricted to draft status to prevent unintended publishing, and a rate-limiting mechanism guards the generation endpoint against abuse. The release includes full unit test coverage for both endpoints and updated documentation throughout.REST API Architecture:
includes/class-rest-api.phpimplementingGET /waygate/v1/patternsfor retrieving available block patterns andPOST /waygate/v1/pagesfor triggering AI page generation, both protected by WordPress nonce and capability checks.post_status: draft, ensuring generated content requires explicit editorial review before publication.Testing:
tests/Unit/RestApiTest.phpwith unit tests covering endpoint registration, authentication enforcement, draft-status enforcement, rate limiting behavior, and valid page creation responses.tests/bootstrap.phpto include the new REST API class in the test autoloading context.Documentation and Version Housekeeping:
README.mdupdated with a dedicated REST API section covering endpoint signatures, authentication requirements, and the draft-only constraint introduced in v0.7.0.CHANGELOG.mdupdated with a[0.7.0]entry documenting all new endpoints, security controls, and behavioral restrictions.docs/ROADMAP.mdmarks both Prompt Templates and REST API as complete, reflecting the current feature state of the plugin.Files Changed:
CHANGELOG.md(Modified)README.md(Modified)docs/ROADMAP.md(Modified)tests/bootstrap.php(Modified)waygate.php(Modified)includes/class-rest-api.php(Added)tests/Unit/RestApiTest.php(Added)