Class TaskController

java.lang.Object
com.homannsoftware.tasks.task.TaskController

@RestController @RequestMapping("/api/tasks") public class TaskController extends Object
Maps task HTTP requests to use cases and returns explicit API DTOs.
  • Constructor Details

    • TaskController

      public TaskController(TaskService tasks)
      Receives the application service through constructor injection.
      Parameters:
      tasks - service implementing task use cases
  • Method Details

    • create

      @PostMapping public org.springframework.http.ResponseEntity<TaskView> create(@Valid @RequestBody @Valid CreateTask request)
      Creates a task after Spring MVC validates the request body.
      Parameters:
      request - validated title input
      Returns:
      HTTP 201 with the created task and its resource Location
    • list

      @GetMapping public List<TaskView> list()
      Lists the tutorial dataset.
      Returns:
      HTTP response body listing all tasks in ascending ID order
    • get

      @GetMapping("/{id}") public TaskView get(@PathVariable long id)
      Reads a task identified by a URL path segment.
      Parameters:
      id - requested task identity
      Returns:
      HTTP response body describing the task
      Throws:
      TaskNotFound - if no task has that identity; mapped to HTTP 404
    • complete

      @PutMapping("/{id}/completion") public TaskView complete(@PathVariable long id)
      Sets completion using an idempotent HTTP operation with no request body.
      Parameters:
      id - requested task identity
      Returns:
      HTTP response body showing the completed task
      Throws:
      TaskNotFound - if no task has that identity; mapped to HTTP 404
    • delete

      @DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> delete(@PathVariable long id)
      Removes an existing task.
      Parameters:
      id - requested task identity
      Returns:
      HTTP 204 with no response body
      Throws:
      TaskNotFound - if no task has that identity; mapped to HTTP 404