It is currently impossible to add certain endpoints without breaking existing ones. For example, if you have the following endpoints:
DELETE /api/discussions/{id}
You would not be able to add custom endpoints with the following paths:
DELETE /api/discussions/all
because the pattern which catches the ID for the existing endpoint would also catch all. But if the custom endpoint was added before the existing, the problem would be solved.
Of course another way to solve this would be to enforce that the id parameter is an integer:
DELETE /api/discussions/{id:\d+}
but while that might be applicable for this example, other routes such as the GET one allow using slugs.
Similar to https://github.com/flarum/framework/pull/4106
Adds:
endpointsBefore('name', fn () => [ ... ])
endpointsAfter('name', fn () => [ ... ])
endpointsBeforeAll(fn () => [ ... ])
It is currently impossible to add certain endpoints without breaking existing ones. For example, if you have the following endpoints:
DELETE /api/discussions/{id}
You would not be able to add custom endpoints with the following paths:
DELETE /api/discussions/all
because the pattern which catches the
ID
for the existing endpoint would also catchall
. But if the custom endpoint was added before the existing, the problem would be solved.Of course another way to solve this would be to enforce that the
id
parameter is an integer:DELETE /api/discussions/{id:\d+}
but while that might be applicable for this example, other routes such as the
GET
one allow using slugs.