You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new implementation of Tobyz\JsonApiServer\Endpoint\EndpointInterface - look at the existing implementations for examples (Show, Create, etc). Something like this:
classMyActionimplementsEndpointInterface
{
publicstaticfunctionmake(): static
{
returnnewstatic();
}
publicfunctionhandle(Context$context): ?ResponseInterface
{
// Endpoint to handle POST /{resource}/my-action$segments = explode('/', $context->path());
if (count($segments) !== 2 || $segments[1] !== 'my-action') {
returnnull;
}
if ($context->method() !== 'POST') {
thrownewMethodNotAllowedException();
}
// Do stuff with $context->resource, $context->body(), etcreturnnewResponse(204);
}
}
Then just add a new instance of your endpoint to the endpoints() array for any resources that should support it:
For implementing behavior not defined by the spec.
Something like:
Call via:
The text was updated successfully, but these errors were encountered: