Sobes.tech
Junior — Middle

Was a service implementing the REST architectural style developed in your last project?

sobes.tech AI

Answer from AI

Yes, in my last project, a REST service was implemented in Java using Spring Boot. It provided an API for managing resources, using standard HTTP methods: GET for retrieving data, POST for creating, PUT for updating, and DELETE for deleting.

Example of a controller in Spring Boot:

@RestController
@RequestMapping("/api/items")
public class ItemController {

    @GetMapping
    public List<Item> getAllItems() {
        // logic to get all items
    }

    @PostMapping
    public Item createItem(@RequestBody Item item) {
        // logic to create an item
    }

    @PutMapping("/{id}")
    public Item updateItem(@PathVariable Long id, @RequestBody Item item) {
        // logic to update an item
    }

    @DeleteMapping("/{id}")
    public void deleteItem(@PathVariable Long id) {
        // logic to delete an item
    }
}

This approach complies with REST architecture, where resources are represented by URIs, and operations are performed using HTTP methods.