Junior — Middle
Have you worked with REST API architecture in your projects?
sobes.tech AI
Answer from AI
Yes, I have worked with REST API architecture in my Java projects. REST (Representational State Transfer) is an architectural style for building web services that uses standard HTTP methods (GET, POST, PUT, DELETE) to interact with resources.
In Java, frameworks like Spring Boot with annotations such as @RestController, @GetMapping, @PostMapping, etc., are often used to create REST APIs.
Example of a simple REST controller in Spring Boot:
@RestController
@RequestMapping("/api/items")
public class ItemController {
@GetMapping("/{id}")
public Item getItem(@PathVariable Long id) {
// logic to get item by id
}
@PostMapping
public Item createItem(@RequestBody Item item) {
// logic to create a new item
}
}
REST API allows clients to interact with the server through standard HTTP requests, which simplifies integration and scaling.