Thursday, January 4, 2018

REST tutorial : Controller layer

Greetings!

This is the last post of our RESTful webservice section 1 ;) . Previous part is here
We still have to implement error handling, security etc

You can find the complete source code here Todoapp

Step 1: Create TodoController annotated with @RestController


Step 2: Implement our methods. Spring will do the REST ;)


Let's test our service using Postman.
start the server, gradle clean bootrun

Test 1: Empty Todos
Note the status: since we do not have any Todos yet, it is 404



Test 2: Create a Todo
We get the 201 status and created Todo's location in header



Test 3: List Todos



Test 4: Update a Todo



Test 5: Delete a Todo




That is all for now, though it is working we are yet to handle errors properly and secure our end points.

No comments:

Post a Comment