-
Notifications
You must be signed in to change notification settings - Fork 17
controller
Pierre Besson edited this page Aug 12, 2014
·
4 revisions

In order to expose an API, you have to map url to route wich trigger specific actions. We assume that our application is RESTFULL. It means a route is able to CREATE, RETRIEVE, UPDATE, DELETE an object: CRUD
- A controller should match a simple route with the following actions
- GET => Should load an object (somtimes with a param)
- POST => Should create an object or be use in order to load.
- PUT => Should update an object.
- DELETE => Delete an object (often take an id paramater)
- In order to have a controller for a contact: (CRUD)
http://domainName/contact** => CREATE a contact

http://domainName/contact/1 => RETRIEVE all contacts

http://domainName/contact/1 => RETRIEVE a contact with an id 1

http://domainName/contact/1 => UPDATE a contact with an id 1

http://domainName/contact/1 => DELETE a contact with an id 1

In order to easily test web apis, you can use two tools:
The network tab of the chrome dev tools (it means you have to write JS code in order to perform ajax requests for other request than GET and visualize them).

The POSTMAN chrome extension.
