Answer the question
In order to leave comments, you need to log in
Long addresses for API - is it normal?
I have a nested entity structure: a page is created, pictures are created for the page, links are created for each picture. That is, you need crud for the page, picture and link. I do like this:
Route::post('pages/create', '[email protected]');
Route::post('pages/{page}/delete', '[email protected]');
Route::post('pages/{page}/images/create', '[email protected]');
Route::post('pages/{page}/images/{image}/update', '[email protected]');
Route::post('pages/{page}/images/{image}/delete', '[email protected]');
Route::post('pages/{page}/images/{image}/links/create', '[email protected]');
Route::post('pages/{page}/images/{image}/links/{link}/update', '[email protected]');
Route::post('pages/{page}/images/{image}/links/{link}/delete', '[email protected]');
Answer the question
In order to leave comments, you need to log in
Can be shortened by using HTTP methods according to their semantics.
POST new entity creation
PATCH, UPDATE change
DELETE delete
It would be possible to make them shorter (not nested), but with this approach it is immediately clear that the picture is from the page.And why is it necessary to make it clear, for what purpose?
'pages/'
'pages/{page}/'
'pages/{page}/images/'
'images/{image}/'
'images/{image}/links/'
'links/{link}/'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question