From 0092d821aeca201321fd87b704ef0ad674f0d95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Thu, 25 May 2023 13:20:15 -0600 Subject: Added GET endpoint to list to dos. Currently the directory is /v1/todos. It'll retrieve a list of all to dos. --- src/main/java/com/encora/Main.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/encora/Main.java') diff --git a/src/main/java/com/encora/Main.java b/src/main/java/com/encora/Main.java index 7591eed..2989919 100644 --- a/src/main/java/com/encora/Main.java +++ b/src/main/java/com/encora/Main.java @@ -3,17 +3,28 @@ package com.encora; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; + +import java.util.List; @SpringBootApplication @RestController +@RequestMapping("v1") public class Main { + private final ToDosRepository toDosRepository; + + public Main(ToDosRepository toDosRepository) { + this.toDosRepository = toDosRepository; + } + public Main() { + this.toDosRepository = new ToDosRepository(); + } + public static void main(String[] args) { SpringApplication.run(Main.class, args); } - @GetMapping("/greet") - public String greet() { - return "Hello world!"; + @GetMapping("/todos") + public List getToDos() { + return toDosRepository.findAll(); } } -- cgit v1.2.3