Posts

Richardson maturity model

 Richardson maturity model :      Measure the level of your REST services : Level 0 :  Expose SOAP web services to RESTful style                         this stage : Improper use of HTTP methods SOAP endpoints                    eg : http://server/getPosts                      http://server/deletePosts      Level 1: Expose Resources with proper URI but this level REST has improper use of HTTP methods.             REST endpoints:           http://server/accounts       http://server/accounts/1 Level 2: LEVEL 1 + HTTP METHODS  LEVEL 3 :  LEVEL 2 + HATEOAS + NEXT POSSIBLE ACTIONS ON THE RESOUCES  BEST practices :    1. CONSUMER FIRST           ...

REST API Versioning

Image
 REST API Versioning :

REST Spring coding

Image
Problem : 1. By default when you invoke any REST URI ,if it is success then it returns 200k but we want to return specific HTTP STATUS based on the operation. eg ; Creation --> should return 201   Solution : @PostMapping ( "users/user" ) public ResponseEntity < User > createUser( @RequestBody User user ) userDaoService . save(user) ( ;                 //This will add the location of the resource in the header URI uri = ServletUriComponentsBuilder . fromCurrentContextPath () . path ( "users/{id}" ) . buildAndExpand( user . getId()) . toUri () ;   return ResponseEntity . created ( uri ) . build() ;  o/p:      It does not return anything in the body, but it contains the location of the resource created in the header section and also notice 201 status. 2. Problem      When the resource does not found, by default,REST API returns 500 internal server Error...