aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/encora/Main.java
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-25 13:20:15 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-25 13:20:15 -0600
commit0092d821aeca201321fd87b704ef0ad674f0d95b (patch)
treead538c157c6c5f3a4b9299eae93c05b0c5529952 /src/main/java/com/encora/Main.java
parent70381b3187aab32d4facb74d327ac79bbc2669ba (diff)
downloadToDo-App-BE-0092d821aeca201321fd87b704ef0ad674f0d95b.tar.gz
ToDo-App-BE-0092d821aeca201321fd87b704ef0ad674f0d95b.zip
Added GET endpoint to list to dos.
Currently the directory is /v1/todos. It'll retrieve a list of all to dos.
Diffstat (limited to 'src/main/java/com/encora/Main.java')
-rw-r--r--src/main/java/com/encora/Main.java19
1 files changed, 15 insertions, 4 deletions
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<ToDos> getToDos() {
+ return toDosRepository.findAll();
}
}