How to Build Rest API Identify Resources: (/user, /user/{id}) etc. Identify Actions (GET, POST, PUT, DELETE, PATCH etc.) Defining Request and Response Structure Define Response Status( 200 as Ok, 404 as Page Not Found, 500 Internal Server Error) 400 Series Errors: Client Side Error 500 Series Errors: Server Side Error Best Practices for Rest API 1.Thinking on Consumer Perspective 2. validation 3 Internationalizations -i18n 4. Exception Handling 5. HATEOAS 6. Versioning 7. Documentation 8. Content Negotiation etc. Internal Working of Spring Boot 1. How to Handle Request in Spring Boot? Dispatcher Servlet- Front Controller Pattern Mapping Servlets: dispatcher Servlet urls=[/] ( as dispatcher servlet is mapped to the [/] root URL) If you search for Mapping servlets you will find out the given below string in logs which is telling to you dispatcher servlet is ma...
How to User Path variable @ PathVariable is used for add the variable in the path of your URL and use into the code @RestController @RequestMapping (path = "/by" ) public class ByWorldController { @GetMapping (path = "/hello-world/path-variable/{name}/{gender}" ) public HelloWorldBean helloWorldPathVariable( @PathVariable String name , @PathVariable String gender ) { if ( gender . equalsIgnoreCase ( "m" )) { return new HelloWorldBean(String. format ( "Hello Mr %s" , name )); } else if ( gender . equalsIgnoreCase ( "f" )) { return new HelloWorldBean(String. format ( "Hello Mrs %s" , name )); } ...
Comments
Post a Comment