Explanation Api Samples Explanations?

I am new to creating leisure api.

I want to know how rest api routing works. I have an api that works in one routing and not in another. What exact changes do I need to make in order to bind each api call to a specific VERB.

for example, I want / customer / view, which is called only by the GET verb, put and post cannot make this call, is this possible with route settings

here are my routes ..

which works here:

'<controller:\w+>'                   => '<controller>/list',
'<controller:\w+>/<action:\w+>'      => '<controller>/<action>',
'<controller:\w+>/<id:\d+>/<title>'  => '<controller>/view',
'<controller:\w+>/<id:\d+>'          => '<controller>/view',

The one that doesn't work is ... especially the kind that is called like that, basically I can call it from any VERB, how to attach to a specific verb

https://myipaddress/wiz-frontend-himanshu/customer/view/?id=test

recreation routes

array('customer/list', 'pattern'=>'customer/<model:\w+>', 'verb'=>'GET'),
array('customer/view', 'pattern'=>'customer/<model:\w+>/<id:\w+>', 'verb'=>'GET'),
array('customer/update', 'pattern'=>'customer/<model:\w+>/<id:\d+>', 'verb'=>'PUT'),
array('customer/delete', 'pattern'=>'customer/<model:\w+>/<id:\d+>', 'verb'=>'DELETE'),
array('customer/create', 'pattern'=>'customer/<model:\w+>/<id:\d+>', 'verb'=>'POST'),

Can someone explain what this template does for sure, and what changes do I need to make to trigger my view call

+4
1

, , , :

api (, , api), URL:

// GET
array('api/<controller>/list', 'pattern'=>'api/<controller:\w+>', 'verb'=>'GET'),
array('api/<controller>/view', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'GET'),
// POST
array('api/<controller>/create', 'pattern'=>'api/<controller:\w+>', 'verb'=>'POST'),
// PUT
array('api/<controller>/update', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'PUT'),
array('api/<controller>/update', 'pattern'=>'api/<controller:\w+>', 'verb'=>'PUT'),
// DELETE
array('api/<controller>/delete', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'DELETE'),
array('api/<controller>/delete', 'pattern'=>'api/<controller:\w+>', 'verb'=>'DELETE'),

, api URL:

GET:/api/users - (actionList() users)

GET:/api/users/12 - id = 12 (actionView() users)

POST:/api/user - (actionCreate() users)

PUT:/api/user/12 - id = 12 (actionUpdate() users)

DELETE:/api/user/12 - id = 12 (actionDelete() users)

+2

Source: https://habr.com/ru/post/1543568/


All Articles